title: how to get the respective array key value if it meets the if condition in for loop
body: <p>I have any array with keys and values , I want to get the value of the key ,if key is equal to certain string.</p>
  
  <p>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.</p>
  
  <pre><code>$grouparray =[ "red" =&gt; "4" , "blue" =&gt;"5" , "green" =&gt; "6"];
  
  foreach($grouparray   as $x=&gt;$x_value){
            if($x=blue){
                $group_id=$x_value;
  
            }
  
        }
  
  print_r($group_id);
  </code></pre>
  
  <p>I want to expect <code>$group_id = 5;</code></p>