hi, i was wondering how i can use php to echo random phrases/quotes like

'blah blah blah'
'asldhasf kdjhfskjf hsjdhf'

and so on.

i did find something like this..

<?
//Chooses a random number
$num = Rand (1,6);
//Based on the random number, gives a quote
switch ($num)
{
case 1:
echo "Time is money";
break;
case 2:
echo "An apple a day keeps the doctor away";
break;
case 3:
echo "Elmo loves dorthy";
break;
case 4:
echo "Off to see the wizard";
break;
case 5:
echo "Tomorrow is another day";
break;
case 6:
echo "PHP is cool!";
}
?>

but for some reason, taht seems like it takes up too much space and too much time

i want a very simple script that is minimal and still works

    I would look into using arrays.

    <?
    quotes_array = array("quote1", "quote2", "quote3", "quote4");
    
    $num = Rand (1,6);
    
    echo $quotes_array[$num];
    ?>
    
    

    Don't know if that is all correct, but should give a good enough of an idea on how to get it working.

      should i change the $num = Rand (1,6); to something like 1,4 since there are only four quotes?

        The example should be:

        <?php
        quotes_array = array("quote1", "quote2", "quote3", "quote4");
        
        echo array_rand($quotes_array);
        ?>

          A long-established convention for storing this sort of information (when the number of entries gets large) is the so-called cookie jar: a separate file looking like:

          Time is money
          %
          An apple a day keeps the doctor away
          %
          Elmo loves dorthy
          %
          Off to see the wizard
          %
          Tomorrow is another day
          %
          PHP is cool!
          %
          Shall we make a new rule of life from tonight:
          always to try to be a little kinder than is necessary?
          		-- J.M. Barrie
          %
          Shame is an improper emotion invented by
          pietists to oppress the human race.
          		-- Robert Preston, Toddy, "Victor/Victoria"
          %
          Shannon's Observation
          	Nothing is so frustrating as a bad situation
          	that is beginning to improve.
          %
          share, n:
          	To give in, endure humiliation.
          %
          Shaw's Principle:
          	Build a system that even a fool can use,
          	and only a fool will want to use it.
          

          Read the file in as one wodge of text, explode it on "\n%\n" and you have your array. (If you do need a line that consists only of a single '%', store it as '%%' and remove the extra '%' when you find it.)

            Write a Reply...