I have a wierd problem. I am creating a variable called $song. It creates a series of HTML Tables. I am building it within a while statement. In the while statement the variable exists fine, but when I attempt to echo the variable just after the while statement closes, it is dramatically different. It's like to only the last line is in the while statement.
Any ideas???
Thanks
Joe
<?php
$fd = fopen ("songs/Ah Lord God.pro", "r");
while (!feof ($fd)) {
$done = 0;
$line = fgets($fd, 2048);
if (preg_match ("/^{/i", $line)) {
$done =1;
};
$offset = 0;
$row1 = "<tr>";
$row2 = "<tr>";
##########Process First
# Do stuff. Populate row 1 & 2
#finish up
#close rows
$row1 = $row1 . "</tr>";
$row2 = $row2 . "</tr>";
#check spaces
$row2 = str_replace(" ", " ", $row2);
#close table
$song = "<table cellpadding=0 cellspacing=0 border=0>";
$song = $song . $row1;
$song = $song . $row2;
$song = $song . "</table>";
#this prints complete
echo $song
};
this prints just the last table
echo $song;
$fd2 = fopen ("templates/default.tpl", "r");
while (!feof ($fd2)) {
$line = fgets($fd2, 4096);
$line = str_replace("%title%", "Testing", $line);
$line = str_replace("%song%", $song, $line);
echo $line;
}
fclose ($fd);
fclose ($fd2);
echo "After";
echo $song;
?>