I have an array that relates mp3 files and their respective lengths in seconds
$playlist = array( array("song" => "01.mp3","min" => "91"),
array("song" => "02.mp3","min" => "101"),
array("song" => "03.mp3","min" => "143"),
array("song" => "04.mp3","min" => "143"),
array("song" => "05.mp3","min" => "151")
);
The I pluck a song from the playlist with array_rand()
...
$song = $playlist[array_rand($playlist)];
Then, later on, I access the values from that array...
echo $song['song'];
//Then somewhere else...
echo $song['min'];
My question is, each time I request $song
, is it going to produce a random result, or does it only produce a random result once per page load? (ie, once $song is defined, it's defined for good.) ...I'm hoping it's the latter.
$song
is assigned only at creation, it will remain the same for the remainder of that request / the variables lifetime. – Wrikken Apr 22 at 18:36