Transform a PHP array to a Javascript array -


Actually I used to change these codes:

  echo" & lt; script & gt; "; Echo "var img_array = new array ();"; Forex Currency ($ img_arr $ img_url) {$ url = (string) $ img_url; Echo "img_array.push ('. $ Url.' '' '); ";} Echo" console.log (img_array); "; echo" & lt; However, errors occur (firefox debug window):  
  error : Endless string source source file: http: //127.0.0.1/CubeCart/index.php?a_a = Account line: 1, column: 42 source code: var img_array = new array (); img_array.push ('http: //gtms01.alicdn.com/tps/i1/T1mL3LFhhhXXaCwpjX.png  

But after I checked the html page souce file, the script is shown as:

< Img_array = new array (); img_array.push ('http://gtms01.alicdn.com/tps/i1/T1mL3LFhhhXXaCwpjX on pre & gt; code & gt; & lt; script & gt; Png '); img_array.push (' http://gtms01.alicdn.com/tps/ i1 / T1DQtTFsdFXXaCwpjX.png '); console.log (img_array); .
< / Pre>

with which I do not see anything is wrong

Your own php One of the items in the array has a new line. Use it:

  echo "& lt; script & gt;" echo "var img_array = new array ();" foreach ($ img_arr $ Img_url)) $ {$ Url = (string) $ img_url; Echo "img_array.push ('" .htmlentities (trim ($ url)). "');"; Echo "console.log (img_array);"; Echo "& lt; / script & gt;";  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -