<?php
-
- $array_1 = array();
- $array_2 = array();
-
- $array_1['username'] = "Aseoe";
- $array_1['website'] = "";
-
- $array_2['member']['ancto.net']['username'] = "ancto";
- $array_2['member']['ancto.net']['website'] = ";
-
- $array_2['member']['aseoe.com']['username'] = "aseoe";
- $array_2['member']['aseoe.com']['website'] = "";
-
-
-
- $jsonObj_1 = json_encode($array_1);
-
-
- $jsonObj_2 = json_encode($array_2);
-
-
- class aseoe{
- public $puname = "public name";
- protected $poname = "protected name";
- private $prname = "private name";
-
- public function getName(){
- return $this->name;
- }
-
- }
-
- $aseoeObj = new aseoe();
- $json_aseoe =json_encode($aseoeObj);
-
-
-
-
- $jsonStr = '{"key":"value","key1":"value2"}';
- $json2Array = json_decode($jsonStr,true);
- print_r($json2Array);
$jsonStr='{"key":"value","key1":"value1"}';
json_decode($jsonStr);//转换之后是对象类型
json_decode($jsonStr,true);//转换之后是数组
show-12-467-1.html
true
json数据格式的相互转换
爱思资源网
show-12-467-1.html
report
3201
<?php$array_1=array(); 一维数组$array_2=array(); 二维数组$array_1[& 39;username& 39;]="Aseoe";$array_1[& 39;website& 39;]="http: www aseoe com ";$array_2[& 39;member& 39;][& 39;ancto net& 39;][
|