I have any array with keys and values , I want to get the value of the key ,if key is equal to certain string.
When I use this code I am getting the last key value of array. I have the flexibility to change the array structure also if we want.
$grouparray =[ "red" => "4" , "blue" =>"5" , "green" => "6"];
foreach($grouparray as $x=>$x_value){
if($x=blue){
$group_id=$x_value;
}
}
print_r($group_id);
I want to expect $group_id = 5;