I have a code which selects a random url from a folder like this:
<?php
$urls = glob("videos/*.php");
$random = mt_rand(0, count($urls) - 1);
header ("location: ".$urls[$random]);
exit;
?>
I had help with the $random function, but did not receive an explanation for it.
The code works perfectly. But I'm wondering why it looks like this:
mt_rand(0, count($urls) - 1);
Instead of this:
mt_rand(count($urls));
Aucun commentaire:
Enregistrer un commentaire