title: How to remove an array from a resultset from fetchall
body: <p>I have a result from a mysql query and need to reduce the result by 1 or more arrays based on a condition. Here is what I tried.</p>
  <pre><code>$sth = $dbh-&gt;prepare(&quot;SELECT name, colour FROM fruit&quot;);
  $sth-&gt;execute();
  $result = $sth-&gt;fetchAll();
  print_r($result);
  </code></pre>
  <p>It will create a resultset of:</p>
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [name] =&gt; pear
              [0] =&gt; pear
              [colour] =&gt; green
              [1] =&gt; green
          )
  
      [1] =&gt; Array
          (
              [name] =&gt; watermelon
              [0] =&gt; watermelon
              [colour] =&gt; pink
              [1] =&gt; pink
          )
  
  )
  </code></pre>
  <p>How can I remove the whole array with the name watermelon so it $result contains only the pear element?</p>
  <p>Here is what I tried, but it did not work:</p>
  <pre><code>foreach ($result AS $items=&gt;$vals){
      foreach ($items AS $item=&gt;$value){
      if ($item ==&quot;name&quot; AND $value=='watermelon'){
          unset($result[$items]);
          }
      }
  }
  </code></pre>
  <p>Thanks in advance.
  Jack</p>