Randomized quote display PHP

You can use example below in many different situations, idea is to create a list of quotes in array, and using PHP array_rand(), we can pick random entries out of an array.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
<?php //array of short quotes (taken from http://www.curatedquotes.com/) $array_of_quotes = array( 'I don\'t want to earn my living; I want to live.', 'Life shrinks or expands in proportion to one\'s courage.', 'Life must be lived forwards, but can only be understood backwards.', 'Be the change you wish to see in the world.', 'This is your life, and it\'s ending one minute at a time.', 'Love the life you live, and live the life you love.' ); //array_rand(array, number) $randome_key = array_rand($array_of_quotes); //print out a random quote print $array_of_quotes[$randome_key]; ?>
  • hello thats nice to randomize the quotes .. but how can i display the whole array as randomize .. i only display one quote at each refresh ..... what i am doing is to display the whole randomize array at each refresh .. plz help me
    • Hello, The array is not attached from array_rand($array_of_quotes);, it's only to get a random array key.
New question is currently disabled!