I'm looking to shuffle content on a page so it's always changing order, for example:
hello, goodbye, maybe, tomorrow would then be goodbye, tomorrow, maybe, hello and so on
I found a code on the internet but I was hoping to see if it's correct
For some reason the first word is not centered but to the left of the page? For example:
Hello
LIST
Goodbye
Yes
No
OK
USA
LIST
I could pm the page I'm having a problem with if someone is willing to help
<?php
$string_array = array
('Hello','Goodbye','Maybe','Yes','No','OK','USA');
$text = "";
$string_count = count($string_array);
for($x=0; $x<$string_count;$x++){
$y = 0;
$temp_array = array();
//reset internal pointers for $string_array
foreach($string_array as $key => $value){
$key = $y;
$temp_array[$key] = $value;
$y ++;
}
$string_array = $temp_array;
//generate a random number of appropriate size
$random_number = rand(0,(count($string_array)-1));
//get the text from the array
$string = $string_array[$random_number];
//make a temp array from that string
$piece = array($string);
//delte the string that was used from the array
$string_array = array_diff($string_array,$piece);
//add that string to the part to be printed.
$text .= "$string<center>";
}
echo $text;
?>