title: Unsetting array values in a foreach loop
body: <p>I have a foreach loop set up to go through my array, check for a certain link, and if it finds it removes that link from the array.</p>
  
  <p>My code:</p>
  
  <pre><code>foreach($images as $image)
  {
      if($image == 'http://i27.tinypic.com/29yk345.gif' ||
      $image == 'http://img3.abload.de/img/10nx2340fhco.gif' ||
      $image == 'http://i42.tinypic.com/9pp2456x.gif')
      {
          unset($images[$image]);
      }
  }
  </code></pre>
  
  <p>But it doesn't remove the array entires. It's probably something to do with <code>$images[$image]</code>, as that's not the key of the array entry, only the content? Is there a way to do this without incorporating a counter?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT:</strong> Thanks guys, but now I have another problem where the array entries don't actually get deleted.</p>
  
  <p>My new code:</p>
  
  <pre><code>foreach($images[1] as $key =&gt; $image)
  {
      if($image == 'http://i27.tinypic.com/29yk345.gif')
      $image == 'http://img3.abload.de/img/10nx2340fhco.gif' ||
      $image == 'http://i42.tinypic.com/9pp2456x.gif')
      {
          unset($images[$key]);
      }
  }
  </code></pre>
  
  <p>$images is actuallty a two-dimensional array now hence why I need $images[1]. I have checked and it successfully goes around the array elements, and some elements do actually have some of those URLs in that I wish to delete, but they're not getting deleted. This is my <code>$images</code> array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; useless
              [1] =&gt; useless
              [2] =&gt; useless
              [3] =&gt; useless
              [4] =&gt; useless
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; http://i27.tinypic.com/29yk345.gif
              [1] =&gt; http://img3.abload.de/img/10nx2340fhco.gif
              [2] =&gt; http://img3.abload.de/img/10nx2340fhco.gif
              [3] =&gt; http://i42.tinypic.com/9pp2456x.gif
          )
  
  )
  </code></pre>
  
  <p>Thanks!</p>