I was hoping some one on this forum would be able to help me with my problem. I am relatively new to PHP and therefore do not know a great deal.
What I am trying to achieve is get PHP to display an XML file. I have managed to get that working. However, I would like to have the text displayed in random order.
Example:
<answer><?php echo $name_row[1]</answer>
<answer><?php echo $name_row[2]</answer>
<answer><?php echo $name_row[3]</answer>
The code processed would display
<answer>Windows</answer>
<answer>Linux</answer>
<answer>Unix</answer>
But I would like it to display in a random order each time the php page is processed, rather than in the same order ie. Linux, Unix, Windows or Windows, Unix, Linux etc.
Any help from members on this forum would be greatly appreciated.
Cheers
HELP NEEDED - Display text in random order
Moderator: General Moderators
An idea:
Have something create a random integer between 1 and 3..., but have 1, 2, 3 defined as Windows, etc... And for the second one <> if the first one is equal to 1, 2, 3, exclude whichever was up there, and random between the last two integers, and then the third one would equal whatever else wasn't chosen. What this equals in PHP, I haven't a clue, but could be a good option.
Example:
Spot 1 choses between 1-3. If it equals 2 then:
Spot 2 choses either 1 or 3.
Spot 3 choses the last remaining...
Have something create a random integer between 1 and 3..., but have 1, 2, 3 defined as Windows, etc... And for the second one <> if the first one is equal to 1, 2, 3, exclude whichever was up there, and random between the last two integers, and then the third one would equal whatever else wasn't chosen. What this equals in PHP, I haven't a clue, but could be a good option.
Example:
Spot 1 choses between 1-3. If it equals 2 then:
Spot 2 choses either 1 or 3.
Spot 3 choses the last remaining...