title: PHP Map keys (arrays) Remove by numeric doesn't work?
body: <p>This is my Map class:</p>
  
  <pre><code>/**
   * Map
   *
   * Collection of items, with a key.
   * @Author Jony &lt;artemkller@gmail.com&gt;
   */
  
  Class Map
  {
      /**
       * Annonymous Constructor
       * Sets up the array.
       */
  
      function __construct()
      {
          $this-&gt;map = array();
      }
  
      /**
       * Method add
       * Adds a new item to the collection with a key.
       *
       * Note: Key can NOT be numeric!
       *
       * @param key       The key of the item.
       * @param value     The value of the item.
       * @return void
       */
  
      public function add($key, $value)
      {
          $this-&gt;map[$key] = $value;
      }
  
      /**
       * Contains
       * Checks if an item with specific key exists.
       *
       * @param key The key.
       * @return Boolean
       */
  
      public function contains($key)
      {
          if (!is_numeric($key))
          {
              return (isset($this-&gt;map[$key])) ? true : false;
          }
          else
          {
              $values = array_values($this-&gt;map);
              return (isset($values[$key])) ? true : false;
          }
      }
  
      /**
       * Method remove
       * Removes an item from the collection by key.
       *
       * @param key   The key of the item.
       * @return void
       */
  
      public function remove($key)
      {
          if (!is_numeric($key))
          {
              if (isset($this-&gt;map[$key]))
                  unset($this-&gt;map[$key]);
          }
          else
          {
              $values = array_values($this-&gt;map);
              if (isset($values[$key]))
              {
                  unset($values[$key]);
              }
          }
      }
  
      /**
       * Method get
       * Gets an item from the collection by key.
       *
       * Note: If entered numeric, it will get the key 
       * by it's offset position number. Arrays starting from 0.
       *
       * @param key The key of the item
       * @return Array item value (Either String, Integer, Object).
       */
  
      public function get($key)
      {
          if (!is_numeric($key))
          {
              return (isset($this-&gt;map[$key])) ? $this-&gt;map[$key] : null;
          }
          else
          {
              $values = array_values($this-&gt;map);
              return (isset($values[$key])) ? $values[$key] : null;
          }
      }
  }
  </code></pre>
  
  <p>I wanted to create my own Map type array class (from Java) just for practice and usage sometimes.</p>
  
  <p>Now I am having problems with the contains / remove method.</p>
  
  <p>When I don't use numeric remove/contains it works all fine, the error is mostly with the remove.</p>
  
  <p>When I remove an item by offset (numeric), I don't think it gets removed from the actual array.</p>
  
  <p>Okay, now let's debug it and test.</p>
  
  <pre><code>                $d = new Map();
                  $d-&gt;add("heyy", 55);
                  $d-&gt;remove(0);
                  if ($d-&gt;contains(0))
                  {
                      echo 5555;
                  }
  </code></pre>
  
  <p>Creating a new map object, adding a new value, removing offset 0, checking if exists, if yes <code>echo 5555</code>.</p>
  
  <p><strong>Now, let's do var_dump($values[$key]); after delete:</strong></p>
  
  <p>Result: <code>NULL</code></p>
  
  <p><strong>Before delete:</strong></p>
  
  <p>Result: <code>55</code></p>
  
  <p><strong>Now let's echo $this->map("heyy") after delete:</strong></p>
  
  <p>Result: <code>55</code></p>
  
  <p>Okay, now it means that the item is not getting removed from the array itself.</p>
  
  <p>What I've tried:</p>
  
  <pre><code>            $values = array_values($this-&gt;map);
              if (isset($this-&gt;map[$values[$key]]))
              {
                  unset($this-&gt;map[$values[$key]]);
              }
  </code></pre>
  
  <p>Still doesn't work.</p>
  
  <p><em>What is wrong with this?</em></p>