Este script simple têm como objetivo gerar números randômicos no PHP function initRand () { static $randCalled = FALSE; if (!$randCalled) { srand((double) microtime() * 1000000); $randCalled = TRUE; } } function randNum ($low, $high) {...

Este script simple têm como objetivo gerar números randômicos no PHP
function initRand () { static $randCalled = FALSE; if (!$randCalled) { srand((double) microtime() * 1000000); $randCalled = TRUE; } } function randNum ($low, $high) { initRand(); $rNum = rand($low, $high); return $rNum; } // Exemplo de uso. // setando o mínimo é o máximo que o número aleatório deve chegar $num_imagem = randNum(1,5); // exibindo uma imagem (imagem_1.jpg, imagem_2.jpg, etc.) echo "imagem_". $num_imagem .".jpg";
Seja Membro Gratuítamente

Assine a newsletter para receber em seu email as publicações atualizadas neste blog

Top