OK let's say I have this example of JSON
{
"result": [
{
"id": 1,
"title": "Random Title 1",
"description": "Random Description 1"
},
{
"id": 4,
"title": "Random Title 2",
"description": "Random Description 2"
},
{
"id": 10,
"title": "Random Title 3",
"description": "Random Description 3"
}
]
}
Do you notice how the IDs are spaced out? So if I wanted to get the 2nd one "Random Title 2" it wouldn't be [4] but [2]. Some of my JSON "ids" are skipping because I edit the JSON file... ANyway right now, I want to get the title of a JSON element based on the id. Each JSON element has a different ID.
Here's what I do right now:
$string = file_get_contents("achievements.json");
$json_a=json_decode($string,true);
$getID = $ID_number;
$getit = $json_a['testJSON'][$getID]['title'];
Now, I have the $ID_number but it won't be the same as the array number. The above is wrong... how do I fix it so I search by id
foreachand anif.