title: PHP - remove element in multidimensional array
body: <p>I have this array:</p>
  
  <pre><code>Array ( 
  [0] =&gt; Array ( [0] =&gt; b [1] =&gt; d [2] =&gt; **c** [3] =&gt;a [4] =&gt; ) 
  
  [1] =&gt; Array ( [0] =&gt; **c** [1] =&gt; a [2] =&gt; d [3] =&gt; [4] =&gt; ) 
  
  [2] =&gt; Array ( [0] =&gt; b [1] =&gt; d [2] =&gt; a [3] =&gt; [4] =&gt; )
  
  [3] =&gt; Array ( [0] =&gt; **c** [1] =&gt; d [2] =&gt; a [3] =&gt;b [4] =&gt; )
  
  )
  </code></pre>
  
  <p>and need to delete (unset?) all elements where value is "c" so that one ends up with:</p>
  
  <pre><code>Array ( 
  [0] =&gt; Array ( **[0] =&gt; b [1] =&gt; d [2] =&gt; a [3] =&gt; [4] =&gt;** ) 
  
  [1] =&gt; Array ( **[0] =&gt; a [1] =&gt; d [2] =&gt; [3] =&gt;** ) 
  
  [2] =&gt; Array ( [0] =&gt; b [1] =&gt; d [2] =&gt; a [3] =&gt; [4] =&gt; )
  
  [3] =&gt; Array ( **[0] =&gt; d [1] =&gt; a [2] =&gt;b [3] =&gt;** )
  
  )
  </code></pre>
  
  <p>The element gets removed, and the other elements to shift up. I know that unset does not re-index the array. Cannot get to unset for all multidimensional arrays, but only with one array. Can the arrays be re-indexed afterwards? Appreciate it.</p>
  
  <p>The code BELOW removes elements where the value is equal to "c" but the index of the first element is not re-indexed. Can anyone suggest a solution to re-indexing the inner arrays?</p>
  
  <pre><code>$i=0;
  foreach ($array as $val)
      {
      foreach ($val as $key =&gt; $final_val)
          { 
  
          if ($final_val =="$search_value") 
              {
               unset($array[$i][$key]);
              }
          } 
      i = $i + 1;
      }
  </code></pre>