时间:2021-07-01 10:21:17 帮助过:18人阅读
参数列表:
函数 | 描述 |
---|---|
json_encode | 对变量进行json编码 |
json_decode | 对json格式的字符串进行解码,转换为php变量 |
json_last_error | 返回最后发生的错误 |
For example 1: json_encode
$arr=array("A"=>"a","B"=>"b","C"=>"c","D"=>"d");
echo json_encode($arr);
output:{"A":"a","B":"b","C":"c","D":"d"}
For example 2: json_decode
$arr='{"A":"a","B":"b","C":"c","D":"d"}';
var_dump(json_decode($arr));
var_dump(json_decode($arr,true));
output:
object(stdClass)[1]
public'A' => string 'a' (length=1)
public'B' => string 'b' (length=1)
public'C' => string 'c' (length=1)
public'D' => string 'd' (length=1)
array (size=4)
'A' => string 'a' (length=1)
'B' => string 'b' (length=1)
'C' => string 'c' (length=1)
'D' => string 'd' (length=1)
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介绍了php json函数,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。