i want help for geting a .swf file sequentially

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
cnu123
Forum Newbie
Posts: 4
Joined: Thu Jul 07, 2005 8:07 am

i want help for geting a .swf file sequentially

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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)];
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
cnu123
Forum Newbie
Posts: 4
Joined: Thu Jul 07, 2005 8:07 am

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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)?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply