I want to get a specific value of a variable from multi array, if the condition matches.
When I print my array:
print_r($myarray);
gives array like this:
Array
(
[0] => Array
(
[id] => 21 //check for this value
[customer_id] => 12456 //get this value
[date] => 12-06-2017
)
[1] => Array
(
[id] => 15
[customer_id] => 12541
[date] => 12-06-2017
)
[2] => Array
(
[id] => 12
[customer_id] => 25415
[date] => 12-06-2017
)
)
I am trying to get customer number if the ID matches with 21
foreach ($myarray as $array){
if($array[][id] == "21"){ //this is where I'm making mistake
$cust_id = $myarray[]['customer_id'];
return $cust_id;
}
}