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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -