I've found an almost similar problem on this topic Loop Multidimensional PHP arrays My array is a little different but almost similar:
Array
(
[size] => int (995)
[data] => Array
(
[0] => Array
(
[service] => 8000
[network] => xxx.xxx.xxx
)
[1] => Array
(
[service] => 9000
[network] => xxx.xxx.xxx
)
[2] => Array
(
[service] => 9500
[network] => xxx.xxx.xxx
)
)
)
I d like to check all the service
values in order to see if the number entered by the user is valid and exists, and display the corresponding network
Here is my naïve try:
$record = NULL;
// let's assume $x as this array here
foreach($record in $x['data']){
if($record['service'] == $bus){
break;
}
}
if($record){
// record found
var_dump($record);
}else{
echo "Not found";
}