このjson出力を以下のスタイルに変更したいのですが、何かアイデアはありますか?
私のコード:
$queryFunctions = $db->getChatRoomData($userID , $userName, $userMessage, $roomID);
$rows['roomInfo'] = array();
while ($result = mysql_fetch_array($queryFunctions, MYSQL_ASSOC))
{
$row['uid'] = $result['uid'];
$row['name'] = $result['userName'];
$row['message'] = $result['messageText'];
array_push($rows, $row);
}
echo json_encode($rows);
現在の出力:
{"roomInfo":[],"0":{"uid":"50","name":"ali","message":"arz adab !"},"1":{"uid":"50","name":"ali","message":"arz adab !"},...}
必要な出力:
{"roomInfo" : [{"uid":"50","name":"ali","message":"arz adab !"},{"uid":"50","name":"ali","message":"arz adab !"},...}
前もって感謝します