次の形式でjsonを印刷する必要があります
> { header: [ { "signinpage": "ABC" }, { "signinpage": "XYZ" }, {
> "signinpage": "PQR" }, { "signinpage": "ERT" } ] }
私は次のコードを使用しました:
while ($row = mysql_fetch_array($res,MYSQL_ASSOC))
{
$rows[] = $row["customer"];
}
if(mysql_num_rows($res)!= 0)
{
if (!isset($responses[$row['$header']= array ()]))
{
for ($i=0;$i<count($rows);$i++)
{
if(isset($responses[$row['$header']]))
{
$responses[$row[$header]] = array('signinpage'=>$rows[$i]);
}
}
}
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json; charset="utf-8"');
echo json_encode($responses);
}
私はJSONを初めて使用しますが、印刷が難しいと感じた場合、目的の出力を取得するために誰かが助けてくれます。よろしくお願いします。