|
<?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"}]
|
|
$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."}
|
|
$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"}
|
|
$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"}
|