encode javascript array in php? -
i tried encode javascript array in php
doesn't work... don't understand problem:
this javascript code
var reports = [ ["grup",24.5,101.6,"680 c.","680 c.",0,"n"], ["vul-aca",4.501,-9.876,"192 c.","192 c.",0,"n"] ];
and tried encode in way:
$file= "jsfolder/array.js"; //here there js array $file_contents = file_get_contents($file); $json_string_array = substr($file_contents,strpos($file_contents,'['),-1); $array_php = json_decode($json_string_array);
but think mistake :(
thank lot , sorry english
you have rid of semicolon end of string too.
php > var_dump(json_decode("[];")); null php > var_dump(json_decode("[]")); array(0) {}
Comments
Post a Comment