作者共發了4篇帖子。
PHP5.2已经支持json了
1樓 巨大八爪鱼 2015-1-25 10:23
<?php
$arr = array(array("id" => 1, "name" => "James"), array("id" => 2, "name" => "Iris"), array("id" => 3, "name" => "Mamá", "nickname" => "Difícil"));
$str = json_encode($arr);
echo $str;
?>

[{"id":1,"name":"James"},{"id":2,"name":"Iris"},{"id":3,"name":"Mam\u00e1","nickname":"Dif\u00edcil"}]
2樓 巨大八爪鱼 2015-1-25 10:25
$arr = array(array("id" => 1, "name" => "James"), array("id" => 2, "name" => "Iris"), array("id" => 3, "name" => "Mamá", "nickname" => "Difícil"), "Español" => "El libro está en la caja.");

{"0":{"id":1,"name":"James"},"1":{"id":2,"name":"Iris"},"2":{"id":3,"name":"Mam\u00e1","nickname":"Dif\u00edcil"},"Espa\u00f1ol":"El libro est\u00e1 en la caja."}
3樓 巨大八爪鱼 2015-1-25 10:27
$arr = array(array("id" => 1, "name" => "James"), array("id" => 2, "name" => "Iris"), array("id" => 3, "name" => "Mamá", "nickname" => "Difícil"), "Español" => "El libro está en la caja.", "Traditional Chinese" => "台灣正體中文");

{"0":{"id":1,"name":"James"},"1":{"id":2,"name":"Iris"},"2":{"id":3,"name":"Mam\u00e1","nickname":"Dif\u00edcil"},"Espa\u00f1ol":"El libro est\u00e1 en la caja.","Traditional Chinese":"\u53f0\u7063\u6b63\u9ad4\u4e2d\u6587"}
4樓 巨大八爪鱼 2015-1-25 10:33
$arr = array();
$arr["English"] = "Where are you from?";
$arr["Español"] = "¿De dónde eres?";
$arr["Chinese"] = "你從哪裡來?";
$str = json_encode($arr);
echo htmlspecialchars($str)."<br><br>";

{"English":"Where are you from?","Espa\u00f1ol":"\u00bfDe d\u00f3nde eres?","Chinese":"\u4f60\u5f9e\u54ea\u88e1\u4f86\uff1f"}

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
 
 
©2010-2024 Arslanbar [手機版] [桌面版]
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。