1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP PHP Random

Discussion in 'Web Development' started by vareside, Feb 8, 2009.

  1. vareside

    vareside New Member

    Hi folks,

    I need help. I need a script that displays pre-defined HTML codes in a random order. Could someone help me by creating such a small script for me?
     
  2. vareside

    vareside New Member

    no Need

    I created one myself. Here we go:
    PHP:
    $text_1 "some text";
    $text_2 "some text2";
    $text_3 "some text3";
    $text_4 "some text4";

    $total_texts rand(1,4);
    echo 
    "<blockquote>&ldquo;".${text_.$total_texts}."&rdquo;</blockquote>";
    See example at WISE QUOTE on http://vareside.com/
     
  3. candycrate

    candycrate New Member

    PHP:
    // Random HTML codes
    $Random_Values=array('text1','text2','text3');

    // Generate a seed for REAL random numbers
    mt_srand((double)microtime()*1000000);

    // Pick a random code
    echo $Random_Values[mt_rand(0,(count($Random_Values)-1))];