Hi, All.
I'm trying to use PHP to read data from file, and then write it into a JavaScript array (which will be used to create a "news-ticker" bar on the page). The problem is that the PHP echo() function is inserting unwanted line breaks after the quote-mark which starts a string, leading to an "unterminated string literal" error. Example:
Code:
var storyLinks = new Array( "<?php global $lastThree; echo($lastThree[1][1]); ?>",
"<?php global $lastThree; echo($lastThree[2][1]); ?>",
"<?php global $lastThree; echo($lastThree[0][1]); ?>");
Produces the following:
Code:
var storyLinks = new Array( "
http://news.independent.co.uk/world/fisk/article2251354.ece",
"
http://news.bbc.co.uk/1/hi/world/americas/6348049.stm",
"
http://comment.independent.co.uk/commentators/article2258798.ece");
I also get a very similar result if I use a single PHP echo() statement, echo()-ing the quotes and commas as well.
Does anyone know a solution to this, please?
Thanks,
Rob
PS - phpinfo() tells me that I'm using PHP 4.4.4 on Apache 1.3.33 (if that makes a difference).