Source Code for /public/03-lists-and-loops/random-quote.php
<?php
$quotes = [
[
'quote' =>
"People don't verify quotes they read on the Internet.",
'by' => 'Abraham Lincoln'
],
[
'quote' => 'Do or do not, there is no try.',
'by' => 'Yoda'
],
[
'quote' => "Snakes. Why'd it have to be snakes?",
'by' => 'Indiana Jones'
],
[
'quote' => "
I've wrestled with reality for 35 years, Doctor, and I'm
happy to state I finally won out over it.
",
'by' => 'Elwood P. Dowd'
],
[
'quote' => 'At the beep, the time will be ' . date('g:i a'),
'by' => 'The Speaking Clock'
],
];
$random_quote_id = array_rand($quotes);
$random_quote = $quotes[ $random_quote_id ];
?>
<blockquote>
<p>
<?php echo $random_quote['quote']; ?>
</p>
<cite>
<?php echo $random_quote['by']; ?>
</cite>
</blockquote>
<p>
<a href="./random-quote.php">🔄 Get another quote</a>
</p>