json()函數
參數列表:
| 函數 |
描述 |
| 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教程有興趣的朋友有所協助。