title: PHP search in json array
body: <p>I want to get the value of all <em>&quot;name&quot;</em> keys which <em>&quot;category&quot;</em> value is not &quot;Beilagen&quot; or &quot;Aktion&quot;.</p>
  <p>Example of the wanted ouput using the json data below:</p>
  <blockquote>
  <p>Zartweizen mit Gemüse</p>
  <p>Kaiserschmarrn mit Apfelmus</p>
  <p>Gebackene Tintenfischringe mit Knoblauchdip</p>
  </blockquote>
  <p>The solution may be a foreach loop, but I can't really figure out how to make specific searches with that.</p>
  <p>This is my quick fix solution, but as you can see in the json example below, the number of relevant data varies and it's not always 4 names I have to get. It can be more or less than that.</p>
  <pre><code>$name = &quot;1. &quot;.$updateArrayMensa[0][&quot;name&quot;].chr(10).&quot;2. &quot;.$updateArrayMensa[1][&quot;name&quot;].chr(10).&quot;3. &quot;.$updateArrayMensa[2][&quot;name&quot;].chr(10).&quot;4. &quot;.$updateArrayMensa[3][&quot;name&quot;];
  </code></pre>
  <p>Json data example:</p>
  <pre><code>[
     {
        &quot;id&quot;:1542115,
        &quot;name&quot;:&quot;Zartweizen mit Gemüse&quot;,
        &quot;category&quot;:&quot;Tagesgericht 1&quot;,
        &quot;prices&quot;:{
           &quot;students&quot;:1.0,
           &quot;employees&quot;:1.9,
           &quot;pupils&quot;:null,
           &quot;others&quot;:2.4
        },
        &quot;notes&quot;:[
           &quot;veganes Gericht&quot;
        ]
     },
     {
        &quot;id&quot;:1542116,
        &quot;name&quot;:&quot;Kaiserschmarrn mit Apfelmus&quot;,
        &quot;category&quot;:&quot;Tagesgericht 4&quot;,
        &quot;prices&quot;:{
           &quot;students&quot;:2.4,
           &quot;employees&quot;:2.95,
           &quot;pupils&quot;:null,
           &quot;others&quot;:3.45
        },
        &quot;notes&quot;:[
           &quot;mit Antioxidationsmittel&quot;,
           &quot;fleischloses Gericht&quot;
        ]
     },
     {
        &quot;id&quot;:1542117,
        &quot;name&quot;:&quot;Gebackene Tintenfischringe mit Knoblauchdip&quot;,
        &quot;category&quot;:&quot;Aktionsessen 3&quot;,
        &quot;prices&quot;:{
           &quot;students&quot;:2.4,
           &quot;employees&quot;:2.95,
           &quot;pupils&quot;:null,
           &quot;others&quot;:3.45
        },
        &quot;notes&quot;:[
           &quot;mit einer Zuckerart und Süßungsmitteln&quot;,
           &quot;mit Farbstoff&quot;,
           &quot;mit Fleisch&quot;
        ]
     },
     {
        &quot;id&quot;:1542128,
        &quot;name&quot;:&quot;Ananaskompott&quot;,
        &quot;category&quot;:&quot;Beilagen&quot;,
        &quot;prices&quot;:{
           &quot;students&quot;:null,
           &quot;employees&quot;:null,
           &quot;pupils&quot;:null,
           &quot;others&quot;:null
        },
        &quot;notes&quot;:[
           &quot;veganes Gericht&quot;
        ]
     },
     {
        &quot;id&quot;:1542129,
        &quot;name&quot;:&quot;Weiße Schokolade-Himbeer-Cookie&quot;,
        &quot;category&quot;:&quot;Aktion&quot;,
        &quot;prices&quot;:{
           &quot;students&quot;:null,
           &quot;employees&quot;:null,
           &quot;pupils&quot;:null,
           &quot;others&quot;:null
        },
        &quot;notes&quot;:[
           &quot;fleischloses Gericht&quot;
        ]
     }
  ]
  </code></pre>
  <p>Source of this json data: <a href="http://www.openmensa.org/api/v2/canteens/138/days/2015-10-16/meals" rel="nofollow noreferrer">http://www.openmensa.org/api/v2/canteens/138/days/2015-10-16/meals</a></p>