title: PHP foreach loop JSON
body: <p>I know there are like hundreds similar questions on this site, but I just can't get my code working...</p>
  
  <p>I have this JSON</p>
  
  <pre><code>{
  "version":"1.0.0",
  "buildDate":20131029,
  "buildTime":165127,
  
  "lockPath":"..\\var\\lock",
  "scriptPath":"..\\var\\lock",
  "connections":
  [
  {
      "name":"o016561",
      "bez":"GEW-NRW",
      "type":"OVPN"
  },
  {
      "name":"o016482",
      "bez":"GEW-BW",
      "type":"OVPN"
  },
  {
      "name":"o019998",
      "bez":"GEW-SH",
      "type":"OVPN"
  }
  ]}
  </code></pre>
  
  <p>how can I access the "name" values to check if there's an existing file with an equal name?
  I tried</p>
  
  <pre><code>$json_config_data = json_decode(file_get_contents($json_path,true));
  
      foreach($json_config_data-&gt;connections as $connectionName)
      {
          if($connectionName-&gt;name == $fileName)
          {
              $status = 1;
          }
          else
          {
              $status = 0;
          }
      }
  </code></pre>
  
  <p>but I always get <code>$status = 0</code>...
  I think there's an easy solution for this, but I'm pretty new to PHP so I'd be glad for any kind of help.
  Thanks in advice</p>