Jump to content
php.lv forumi

Random bildes izvade


Paulinjsh

Recommended Posts

A šitā gadījumā nevar?

 

shuffle($urlArray);

$urlArray = array_slice($urlArray,0,3);

cik paspaidīju F5 visi ir unikālie ;)

<?php
$a=glob("images/{*.gif,*.jpg,*.jpeg,*.png}", GLOB_BRACE);
shuffle($a);
$a=array_slice($a,0,3);
echo $a[0].'<br />';
echo $a[1].'<br />';
echo $a[2].'<br />';
?>

Edited by blackhalt
Link to comment
Share on other sites

Tik lai pa visam randomiski strādātu, vajadzētu pirms shuffle() ielikt srand((float)microtime() * 1000000);

Tas ja php vecs.

Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically.

Link to comment
Share on other sites

×
×
  • Create New...