I am trying to get all ids from json by using json_decode function for this response.How can I get only id in an array? I really appreciate any help.
Response:
{
"columns": [
"name",
"id",
"sno"
],
"data": [
[
"test1",
"123",
"1"
],
[
"test2",
"456",
"2"
]
]
}
Code:
$obj = json_decode($result, true);
foreach ($obj as $key => $value) {
foreach ($value as $k => $val) {
echo $val;
if ($k == "id") {
array_push($all_ids, $val);
}
}
}