Php random script

Discussion in 'PHP' started by mfp, Dec 31, 2008.

  1. #1
    can anyone tell me from where i can get script like this

    
    http://mumbaihangout.org/rnd.php
    
    Code (markup):

     
    mfp, Dec 31, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    <?php
    
    $urls = array('http://google.com', 'http://website.com', 'http://example.com');
    
    headers_sent() ? die('<a href="' . $urls[rand(0, count($urls)-1)] . '">Go</a>') : header('Location: ' . $urls[rand(0, count($urls)-1)]);
    
    PHP:
     
    Danltn, Dec 31, 2008 IP
  3. mfp

    mfp Guest

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you very much brother....i was really in need of this.. thanks for helping me
     
    mfp, Dec 31, 2008 IP
  4. bhagwat_banna

    bhagwat_banna Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    me too thanks you so much.
     
    bhagwat_banna, Jan 1, 2009 IP
  5. alexus

    alexus Well-Known Member

    Messages:
    746
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #5
    I see:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done
     
    alexus, Jan 1, 2009 IP
  6. Lavinco

    Lavinco Peon

    Messages:
    383
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Here's one:
    You need two files
    name this one random.php
    
    <?php
    
    $RANDOM_TXT_FILE = "data_file.php"; // Absolute path and name to file contain sentances text.
    
    // End  Necessary Variables section
    /******************************************************************************/
    
    srand((double)microtime()*1000000);
    
    if (file_exists($RANDOM_TXT_FILE)) {
    	$arry_txt = preg_split("/--NEXT--/", join('', file($RANDOM_TXT_FILE)));
    	echo $arry_txt[rand(0, sizeof($arry_txt) -1)];
    } else {
    	echo "Error: can't open $RANDOM_IMG_FILE file";
    }
    
    ?>
    Code (markup):
    Name this one data_file.php
    This is where you store the random data seperated by /--NEXT--/
    
    <a href="http://www.areawebsolutions.com">Web Solutions Link</a>
    /--NEXT--/
    <a href="http://www.areawebsolutions.com">Web Solutions Link 2</a>
    /--NEXT--/
    Web Solutions Text
    /--NEXT--/
    Any text
    /--NEXT--/
    any <html> code
    
    Code (markup):
    the random code only serves as examples. Replace with your own text or html
     
    Lavinco, Jan 1, 2009 IP