How to access JSON decoded array in PHP

后端 未结 6 1123
梦谈多话
梦谈多话 2020-12-01 14:23

I returned an array of JSON data type from javascript to PHP, I used json_decode($data, true) to convert it to an associa

6条回答
  •  无人及你
    2020-12-01 14:46

    This may help you!

    $latlng='{"lat":29.5345741,"lng":75.0342196}';
    $latlng=json_decode($latlng,TRUE); // array
    echo "Lat=".$latlng['lat'];
    echo '
    '; echo "Lng=".$latlng['lng']; echo '
    '; $latlng2='{"lat":29.5345741,"lng":75.0342196}'; $latlng2=json_decode($latlng2); // object echo "Lat=".$latlng2->lat; echo '
    '; echo "Lng=".$latlng2->lng; echo '
    ';

提交回复
热议问题