php problem with javascript
Posted: Sat Nov 06, 2004 5:08 pm
hi everyone, i have a problem with my loop. i get all the data out of the file fine but the javascritp won't work due to carrage returns that the php engine seems to put in. this is the current output:
randImgObj.set2=new Array('images/small_modern/m1.jpg
','images/small_history/m1.jpg
');
when i remove the /n my self teh script works fine
this is my php code
<?php
$line ="test";
$i=1;
$filename="test/test.txt";
$fp =fopen($filename, "r") or die("could not open file $filename");
while (! feof($fp)){
$line =fgets($fp,3000);
$t= "randImgObj.set".$i."=new Array('images/small_modern/".$line."','images/small_history/".$line."');";
$t= trim($t);
print $t;
$i++;
}
this is how the out put should look
randImgObj.set2=new Array'images/small_modern/m1.jpg','images/small_history/m1.jpg');
randImgObj.set2=new Array('images/small_modern/m1.jpg
','images/small_history/m1.jpg
');
when i remove the /n my self teh script works fine
this is my php code
<?php
$line ="test";
$i=1;
$filename="test/test.txt";
$fp =fopen($filename, "r") or die("could not open file $filename");
while (! feof($fp)){
$line =fgets($fp,3000);
$t= "randImgObj.set".$i."=new Array('images/small_modern/".$line."','images/small_history/".$line."');";
$t= trim($t);
print $t;
$i++;
}
this is how the out put should look
randImgObj.set2=new Array'images/small_modern/m1.jpg','images/small_history/m1.jpg');