'PHP: How to create json group from mysqli_fetch_all? [duplicate]
I want to make this sample json from 2 mysqli_fetch_all result:
{
"GroupA": {
"5909": "By the sky with the constellations.\n",
"5910": "And by the Promised Day.\n",
"5911": "And by the witness and the witnessed.\n",
"5912": "Destroyed were the People of the Trench.\n",
"5913": "The fire supplied with fuel.\n",
"5914": "While they sat around it.\n"
},
"GroupB": {
"5923": "Possessor of the Glorious Throne.\n",
"5924": "Doer of whatever He wills.\n",
"5925": "Has there come to you the story of the legions?\n",
"5926": "Of Pharaoh and Thamood?\n",
"5927": "In fact, those who disbelieve are in denial.\n",
"5928": "And God encloses them from beyond.\n",
"5929": "In fact, it is a Glorious Quran.\n"
}
}
My php mysqli_fetch_all code is:
$resA = $mysqli->query("SELECT id,text FROM `groupA` WHERE `id` BETWEEN 499 AND 544");
$resB = $mysqli->query("SELECT id,text FROM `groupB` WHERE `id` BETWEEN 600 AND 900");
echo json_encode($group, 256);
How to make this ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
