I want to display a php code at random and so for I have
<?php
// load the file that contain thecode
$adfile = "code.txt";
$ads = array();
// one line per code
$fh = fopen($adfile, "r");
while(!feof($fh)) {
$line = fgets($fh, 10240);
$line = trim($line);
if($line != "") {
$ads[] = $line;
}
}
// randomly pick an code
$num = count($ads);
$idx = rand(0, $num-1);
echo $ads[$idx];
?>
The code.txt has lines like
<?php print insert_proplayer( array( "width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnPCpCVepCg"); ?>
Proplayer is a wordpress plugin that displays a video. The codes in code.txt work well, but not when I use the pick line from code.txt. Instead of the full php line I get:
"width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnPCpCVepCg"); ?>
How can I make the echo show the php code, rather than a txt version of the php code?