I'm trying to display blocks of text from a list of blocks.
I'm thinking that an array makes the most sense...
$quotes[] = array(
'block' => 'Luck is what happens when preparation meets Opportunity.',
'author' => 'Seneca',
);
$quotes[] = array(
'block' => 'Quote number two.',
'author' => 'Author Two',
);
$quotes[] = array(
'block' => 'Quote number three.',
'author' => 'Author Three',
);
Now if I wanted to list the quotes I would do this:
foreach($quotes[] as $quote) {
echo '<div><p>"<i>' . $quote['block'] . '</i>"<br />― ' . $quote['author'] . '</p></div>';
}
But how do I go about listing just one of the quotes randomely?
I was looking around and some people were using while loops
?
The end goal is that wherever I place this piece of code, I want to display a random quote in different parts of my website, so I don't want the same quote to be in every spot.