<?php
//header("Content-type:application/json");
$array = array('A'=>'a', 'B'=>'b', 'C'=>'c');

$j_arr = json_encode($array);


//1.当解析后为非标准格式(Object)
$res = json_decode($j_arr);
echo $res -> A; //输出a

//2.$res为object类型,使用(array)强转换
$arr = (array)$res; 
$arr变回数组,不是object

//3.json_decode($res, TRUE); 最好滴方法
$arr = json_decode($res, TRUE);
$arr变成数组

?>

 

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-10-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案