title: PHP foreach if condition
body: <p>This should be easy, but I can´t seem to get it to work. I have an multidimensional array and I wan´t iterate trough the array and check for a specific value. If the value equals a string then echo out a value of the array.</p>
  
  <p>Here is the array and two values (the full array has a lot more):</p>
  
  <pre><code>$users = array( 
      "username01" =&gt; array("fullname" =&gt; "Firstname Lastname",
                              "status" =&gt; "Online"),
      "username02" =&gt; array("fullname" =&gt; "Firstname Lastname",
                              "status" =&gt; "Offline")
  );
  </code></pre>
  
  <p>I wan't to <code>echo</code> out the Full name of each user that is "Online". Here is what I'm using today but it's not working:</p>
  
  <pre><code>$string = "Online";
  foreach ($users as $username =&gt; $data) {
      $fullname = $data["fullname"];
      $status   = $data["status"];
  
      echo $status."= ";
      if ($status == $string) { 
          echo "Yes"; 
      } else { 
          echo "No"; 
      }
        echo "&lt;br&gt;";
  }
  </code></pre>
  
  <p>If I echo out <code>$fullname</code> and <code>$status</code> the correct data is printed out. But for some reason the IF statement is not working. If the user is Offline the echo is "No", but if the user is Online there is no echo at all.</p>
  
  <p><strong>EDIT - Solved</strong><br>
  Updated the array keys with quotes and $data[...] as was suggested below. I found a typo that was causing a false output. Thanks for all the help.</p>