JSON decode with PHP PDO -
i have json string, , want decode string php array , add database, when try call part of array dont anything:
<?php $json = '{"zoom":13,"tilt":0,"maptypeid":"hybrid","center":{"lat":45.38591280296377,"lng":19.936323169799834},"overlays":[{"type":"polygon","title":"polje 1","content":"vojvodina","fillcolor":"#ffbf1a","fillopacity":0.3,"strokecolor":"#000","strokeopacity":0.8,"strokeweight":3,"paths":[[{"lat":"45.37867863632308","lng":"19.948768615722656"},{"lat":"45.370719925928746","lng":"19.941558837890625"},{"lat":"45.36227764550136","lng":"19.92816925048828"},{"lat":"45.359262240003495","lng":"19.942245483398438"},{"lat":"45.35588479505299","lng":"19.955806732177734"},{"lat":"45.35974471568275","lng":"19.958553314208984"},{"lat":"45.36312193024184","lng":"19.959583282470703"},{"lat":"45.365534102931655","lng":"19.960613250732422"},{"lat":"45.36529289029106","lng":"19.96490478515625"},{"lat":"45.37084052080666","lng":"19.970226287841797"}]]}]}'; $arr = (json_decode($json, true)); echo $arr['paths']; ?>
so why cant print $arr['paths']
???
because array , can't echo
right way.. should make use of print_r
print_r($arr['overlays'][0]['paths']);
output :
array ( [0] => array ( [0] => array ( [lat] => 45.37867863632308 [lng] => 19.948768615722656 ) [1] => array ( [lat] => 45.370719925928746 [lng] => 19.941558837890625 ) [2] => array ( [lat] => 45.36227764550136 [lng] => 19.92816925048828 ) [3] => array ( [lat] => 45.359262240003495 [lng] => 19.942245483398438 ) [4] => array ( [lat] => 45.35588479505299 [lng] => 19.955806732177734 ) [5] => array ( [lat] => 45.35974471568275 [lng] => 19.958553314208984 ) [6] => array ( [lat] => 45.36312193024184 [lng] => 19.959583282470703 ) [7] => array ( [lat] => 45.365534102931655 [lng] => 19.960613250732422 ) [8] => array ( [lat] => 45.36529289029106 [lng] => 19.96490478515625 ) [9] => array ( [lat] => 45.37084052080666 [lng] => 19.970226287841797 ) ) )
Comments
Post a Comment