PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Is there a function that will take a numeric array and just randomize the items within it? I was trying to use shuffle() but it was returning a boolean, and not the rearranged array itself. PHP5 probably has a function that does this, but I'm not having any luck finding it.
$list_shuffled=shuffle($homepage_list_array); // shuffle the order, so the displayed items will be random
while (count($list_shuffled) <= // only take the first 8 because that is all the homepage template can fit
{
array_pop($list_shuffled);
}
return $list_shuffled;
But, I'm getting this error: Warning: array_pop() [function.array-pop]: The argument should be an array in C:\Program Files\xampp\htdocs\dev\hubuy\includes\datasearch.php5 on line 36
// this is correct
$array = array(1,2,3,4,5);
shuffle($array);
print_r($array);
// this is incorrect
$array = array(1,2,3,4,5);
$shuffled = shuffle($array);
print_r($shuffled);
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.