I've got a randomising script like this:
Code: Select all
<?php
$fc = join("",file("/whatever.txt"));
$fc = "$fc\n"; $spl = split("\n",$fc);
srand((double)microtime()*1000000);
$rndnum = (rand()%(count($spl)-1));
echo $spl[$rndnum];
?>This works beautifully when it's outputting HTML etc but I'm trying to get it to output some PHP instead but it's not working properly as the PHP tags and all is visible within the source of the final page.
(The end result is to randomise some adverts that are called using PHP from a WordPress plugin where a line in the .txt file would look like this:
<?php AdServe("boxad1"); ?><?php AdServe("boxad2"); ?><?php AdServe("boxad3"); ?><?php AdServe("boxad4"); ?><?php AdServe("boxad5"); ?>
The next line has the ads in a different order. The idea being that it should call a line, randomly, thus randomising the appearance of the ads)
How can I get this to output the PHP before it displays? Am I going about this completely the wrong way?