Using an answer found here. I am trying to randomly select a URL found for a PHP variable called $url.
Here is the current code:
$url1 = "https://www.domain1.com/tds/parser.php?station=".$_GET['id'];
$url2 = "https://www.domain2.com/tds/parser.php?station=".$_GET['id'];
$vals = array($url1,$url2);
$url = array($vals[array_rand($vals, 1)]);
echo $url;
My echo statement returns just the words 'array' instead of the actual url randomly selected?
var_dump( $url );will reveal your issue.echo $url[0]$url = array($vals[array_rand($vals, 1)]);is confusing and probably unnecessary. Justshuffle($vals);andecho $vals[0];