从PHP创建JSON

从PHP创建JSON,php,json,Php,Json,如何创建这个 [{ "Date" : "2013.01" , "Target" : 120 , "Reach" : 150 , "Change" : 180 } , {“日期”:“2013.02”,“目标”:120,“达到”:150,“改变”:180}] 作为图表所需的数据,从这里输入JSON?谢谢你 作为图表所需的数据,从这里输入JSON?谢谢你 作为图表所需的数据,从这里输入JSON?谢谢你 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//

如何创建这个

[{ "Date" : "2013.01" , "Target" : 120 , "Reach" : 150 , "Change" : 180 } ,
{“日期”:“2013.02”,“目标”:120,“达到”:150,“改变”:180}]

作为图表所需的数据,从这里输入JSON?谢谢你 作为图表所需的数据,从这里输入JSON?谢谢你 作为图表所需的数据,从这里输入JSON?谢谢你

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>www</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
P { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
TD { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
-->
</style>
</head>
<body>

<?php
/*
VIEW-PAGINATED.PHP
Displays all data from 'Admin' table
This is a modified version of view.php that includes pagination
*/

// connect to the database
include('connect-db.php');
// log record
$Time = time().'.'.$extension;
$Log = 'Admin';
$IP = $_SERVER['REMOTE_ADDR'];
$query="INSERT INTO Adminlog (ID, Log, Time, IP)VALUES ('NULL', '".$Log."',
'".$Time."', '".$IP."')";
mysql_query($query) or die ('Error updating database');

print
( '<div align="left">

</div>' );

$result = mysql_query("SELECT * FROM Admin WHERE Student='1221'")
or die(mysql_error());

{
echo "<a href='rtbr.php?page=$I'>$I</a> ";
}

echo "[";
echo "<br>";
while ($row = mysql_fetch_array($result)) {
echo "<td>" . " { "
. " &quot;Date&quot; " . " : " . " &quot;2013.01&quot; " . " , "
. " &quot;Target&quot; " . " : " . $row["SubjectMEScore"] . " , "
. " &quot;Reach&quot; " . " : " . $row["SubjectEEScore"] . " , "
. " &quot;Change&quot; " . " : " . $row["SubjectCCScore"] . " } " . " , "
. "</td>";

echo "<br>";

echo "<td>" . " { "
. " &quot;Date&quot; " . " : " . " &quot;2013.02&quot; " . " , "
. " &quot;Target&quot; " . " : " . $row["SubjectMEScore"] . " , "
. " &quot;Reach&quot; " . " : " . $row["SubjectEEScore"] . " , "
. " &quot;Change&quot; " . " : " . $row["SubjectCCScore"] . " } "
. "</td>";

echo "<br>";

echo "]";

echo "</tr>";
}
// close table>
echo "</table>";

?>

</body>
</html> 

万维网

您只需将数组放入
json\u encode()

所以像这样:

$array = array('first_value', 'second_value');
echo json_encode($array);
PHP将以JSON的形式返回数组

如果你想解码的话,它也很简单。使用
json\u decode()
instaed

echo json_decode($json_array);

这可能是您正在寻找的: