title: How to unset some elements of JSON Array in php
body: <p>I'm trying to unset some elements of JSON Array, so if <strong>pname</strong> value start with <strong>XX</strong> it should unset. Normal JSON String gives me this</p>
  
  <pre><code>$json = str_replace('&amp;quot;', '"', $loc);
  
  [{"uid":"352","pcode1":"AB1","pname":"XXAB1"},....}]
  </code></pre>
  
  <p>If I hardcode <strong>pname</strong> value like this</p>
  
  <pre><code>foreach ($json as $key =&gt; $value) 
       {
          if (in_array('XXAB1', $value)) {
                  unset($json[$key]);
              }
      }
      $j = json_encode($json);
      echo $j;
  </code></pre>
  
  <p>it works unsets that array but how can I do this dynamically ? So that each <strong>pname</strong> value begins with <strong>XX</strong> can be unsets.</p>