How to use an array value from php to javascript? -


It was always a question for me how I can use the array values ​​in JavaScript, whereas that ARF is used to get my php script

For example, read some values ​​from a file and use it in JavaScript.

What is the plan to do this? You can use the function to safely return JSON objects, which you can use directly in javascript:

/ P>
  & lt ;? Php $ phpArray = array ("foo", "bar", "baz"); // .... .... & gt; & Lt; Script type = "text / javascript" & gt; Var JSERE = & lt;? Echo json_encode ($ phpArray); ? & Gt ;; & Lt; / Script & gt;  

Output:

  & lt; Script type = "text / javascript" & gt; Var JSirere = ["EFU", "Bar", "Falcon"]; & Lt; / Script & gt;  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -