作者共发了4篇帖子。 内容转换:不转换▼
 
点击 回复
252 3
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"}

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:252 回复数:3
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2015-1-25 10:33
 
©2010-2024 Arslanbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。