php random link from array -


<?      $urls = array(     array(         'http://cur.lv/xlnc',         'http://cur.lv/xln8',         'http://cur.lv/xln5',         'http://cur.lv/xln4',         'http://cur.lv/xlmv',         'http://cur.lv/xlms',         'http://cur.lv/xllz',         'http://cur.lv/xllp',         'http://cur.lv/xllj',         'http://cur.lv/xlle',         'http://cur.lv/xll9',         'http://cur.lv/xll5',         'http://cur.lv/xlks',         'http://cur.lv/xlkl',         'http://cur.lv/xlke',         'http://cur.lv/xlk4',         'http://cur.lv/xljv',         'http://cur.lv/xlje',         'http://cur.lv/xlj9',         'http://cur.lv/xlj1',         'http://cur.lv/xjxu',         'http://cur.lv/xjxd',         'http://cur.lv/xjx4',         'http://cur.lv/xjwz',         'http://cur.lv/xjw1',         'http://cur.lv/xjup',         'http://cur.lv/xjtz',         'http://cur.lv/xjtt',         'http://cur.lv/xjtn',         'http://cur.lv/xjrh',         'http://cur.lv/xjrd',         'http://cur.lv/xjr3',         'http://cur.lv/xj1z',         'http://cur.lv/xizx',         'http://cur.lv/xizf',         'http://cur.lv/x3jx',         'http://cur.lv/x3jp'     ) );  $randomlink = array_rand($urls, 1); $thelink = $randomlink[0]; echo '<a target="_blank" href="' . $thelink . '">random faucet</a>' ?> 

doesn't seem work trying display 1 of links randomly every click..

change this

 $thelink = $randomlink[0]; 

to

$thelink = $urls[$randomlink]; 

$randomlink = array_rand($urls, 1) 

picks 1 or more random entries out of array, , returns key (or keys) of random entries


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -