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:
& 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
Post a Comment