Page 1 of 1

i want help for geting a .swf file sequentially

Posted: Wed Jul 13, 2005 10:30 am
by cnu123
presently i am using a code for randomly get a file.
here the code:
in this $pval is a string like "s1.swf,s2.swf";


Code: Select all

$files=array();
$files=explode(',',$pval);

$i=count($files)-1;
mt_srand((double)microtime()*1000000000000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
return $files&#1111;$rand];
i wnat help for how to get sequentilay.
plz help me.

Posted: Wed Jul 13, 2005 11:51 am
by John Cartwright

Posted: Wed Jul 13, 2005 12:39 pm
by pickle
Ya, sort should do it. In other news, your random code can be optimized quite a bit:

Code: Select all

//$files=array();
$files=explode(',',$pval);
 
//$i=count($files)-1;
mt_srand((double)microtime()*1000000000000000); // seed for PHP < 4.2
//$rand = mt_rand(0, $i); // $i was incremented as we went along
//return $files[$rand];
return $files[array_rand($files)];

Posted: Thu Jul 14, 2005 12:24 am
by cnu123
hai friends,
i saw your code.
I am calling my random programm in another programm.Presently each time calling that programm i will return randomly a .swf file.
you said use sort.But how the random program preserve last time return .swf file.
Plz tell me.

Posted: Thu Jul 14, 2005 10:03 am
by pickle
Do you want to keep track of the last loaded .swf file on a user by user basis (use cookies), or on a site-wide basis (use a database)?