Main Content

More PHP sample and demonstration programs

Archive - Originally posted on "The Horse's Mouth" - 2007-12-01 01:33:52 - Graham Ellis

It's amazing how many little (and not so little) new programs and demonstrations I write - here are some from the last couple of days:

• The Melksham / Bowerhill Christmas Quiz, 2007. Ten questions, work out the answers, click on a link at the bottom the page and it will be refreshed to tell you the actual results. Uses a data file of questions - would work equally well for Skegness, St Anne's or Aberdovey!

Try the Quiz, source

• An updated demonstration of joining two images with a "tear" - graphic artist effects via the GD module of PHP on your web page.

See a sample, source

• Sorting an Associate Array - and how User Defined Sorts work in PHP. The business of a callback function is quick a new concept to many of our customers, and this demonstration shows how it works ... complete with print statements within the comparator to help explain the algorithm.

See it run, See the source

• Sorting a regular array in PHP - forward, backward, and in a user defined way using a date that's embedded in the line. This demonstration program also shows you how to extract a date and time from a line of data using regular expressions, to convert it to a standard time format (that can be compared, sorted, etc) and then convert it back into a text form that's human or database readable.

Run the demonstration, and look at the source code for it

• There are many ways of looping through a PHP array, and this final example shows many of them compared in the same short program.

Run the program, source