JDT |
FREE Downloads |
|
Using the PHP shuffle() function |
||||
|
The PHP shuffle() function is useful if, for example, you want to extract random items from a database. Here is a very simple script showing how to use shuffle().
<?php This script displays one name from those contained in the array called $name. The names are initially loaded into the array, they are then shuffled using the shuffle() function, and then the first item in the array is printed to the screen. If you go to www.computernostalgia.net, you can see an example of how the shuffle() command is being used to randomly display photos (on the home page) from a database. If you want the code for this, send me an email (john at dixondevelopment.co.uk) and I'll send it to you. Go back to PHP Tutorials home page Go back to Tutorials home page
|