一维数组到json数据格式的转换,没输出来结果。老是在 $jsonObj_1=json_encode($array_1);处显示错误,不知道怎么回事?
静待花开
静待花开 2017-02-15 15:50:01
0
2
1388
<?php
$array_1= array();//一维数组;
  $array_2= array();//二维数组;
   $array_1[’username’]="dfdsf";
   $array_1[’age’]=25;
    $array_2[’nember’][’shjsh’][’username’]="dfdsf";
    $array_2[’nember’][’shjsh’][’age’]=25;
    $array_2[’nember’][’hjhj’][’username’]="ghgj";
    $array_2[’nember’][’hjhj’][’age’]=27;
//print_r($array_2);
 $jsonObj_1=json_encode($array_1);
 echo $jsonObj_1;
 
 
?>


静待花开
静待花开

reply all(2)
数据分析师

Conversion of one-dimensional array to json data format, no result is output. An error always appears at $jsonObj_1=json_encode($array_1);, I don’t know what’s going on? -PHP Chinese website Q&A-Conversion of one-dimensional array to json data format, no result is output. An error always appears at $jsonObj_1=json_encode($array_1);, I don’t know what’s going on? -PHP Chinese website Q&A

Let’s take a look and learn.

刘奇

是你的标点符号有问题啊,不是中文下的‘ ’而是在英文下的' '

   $array_1= array();//一维数组;

   $array_2= array();//二维数组;


   $array_1['username']="dfdsf";

   $array_1['age']=25;


   $array_2['nember']['shjsh']['username']="dfdsf";

   $array_2['nember']['shjsh']['age']=25;


   $array_2['nember']['hjhj']['username']="ghgj";

   $array_2['nember']['hjhj']['age']=27;

   //print_r($array_2);


$jsonObj_1=json_encode($array_1);

echo $jsonObj_1;


?>



Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template