javascript - json_encode array with special character -


i have array

array (size=3)   0 =>      array (size=4)       'lat' => string 'qqq' (length=11)       'lng' => string 'qqq' (length=11)       'housenumber' => string 'xxx' (length=3)       'street' => string 'josé ellauri' (length=12)   1 =>      array (size=4)       'lat' => string 'qqq' (length=11)       'lng' => string 'qqq' (length=11)       'housenumber' => string 'xxx' (length=4)       'street' => string 'francisco solano garcía' (length=23)   2 =>      array (size=4)       'lat' => string 'qqq' (length=11)       'lng' => string 'qqq' (length=11)       'housenumber' => string 'xxx' (length=3)       'street' => string 'ingeniero carlos maría maggiolo' (length=31) 

i trying json_encode array since there special characters, found out need $toreturn = array_map('utf8_encode', $toreturn); i'm getting error. code below.

$toreturn = array_map('utf8_encode', $toreturn); echo json_encode($toreturn); 

im getting error in page.

( ! ) warning: utf8_encode() expects parameter 1 string, array given in c:\wamp\www\resh\backend.php on line 39

this easy can't find error is.

thanks in advance.

this happning because array_map() pass data contains array instead. try -

$toreturn = array_map('encode_all_strings', $toreturn);  function encode_all_strings($arr) {     foreach($arr $key => $value) {         $arr[$key] = utf8_encode($value);     }     return $arr; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -