Load Random Flash Movie?

Hallo fellas,

Need some help with setting up a small php script to load multiple FLV files (located in a single folder on the server) in a random manner.

I found this piece of code by googling A LOT! :^^:


$flashfiles = intval($params->get( ‘flashfiles’ ));
$flashbase = $params->get( ‘/videos’ );
$quality = $params->get( ‘high’);
$background = $params->get( ‘#FFFFFF’);
$width = $params->get( ‘400’ );
$height = $params->get( ‘400’ );

$top = rand (1,$flashfiles);

$content = <<<EOD

EOD; [/php]

However, there are still some problems -

(1) I get an “eval() error in line 2 message”
(2) The flv files that are loaded randomly has to be renamed as “1.flv”, “2.flv”, “3.flv” etc. This is ok if I only have a few files… but I have tonnes of FLVs and I need the randomization to be independent of file name. I would like to have a random FLV loaded up whether or not they are ‘numbered’ in their filename.

Any advice?

Thanks a lot in advance.

This shouldn’t be to hard, you just need to read through the directory that contains all your files.


Take all the valid names found and dump them in to array.

myarray[] = “”;

Next you can just create a random number and use that number to select an index from the array.

Just use count() to count the number of array items, subtract 1 from that and use 0 as the minimum when giving a range of numbers to rand function.

For information on how to use these function, please see http://www.php.net

Thanks for the tip.

I will try my best to read up on those functions.

Might be a little too complicated for me as I am very new to PHP.

Thanks for the pointer anyway… Guess I need to do some reading up! :)

Just give it whirl, you have a question, come back and post again. We are here to help! :)

Sponsor our Newsletter | Privacy Policy | Terms of Service