title: array_map in php with callback OOP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3350762/how-to-use-an-object-method-as-a-callback-function">How to use an object method as a callback function</a>  </p>
  </blockquote>
  
  
  
  <p>Usually I used array_map with procedural code, but in this case I'm working in OOP and the callback should be "this->id2areas", but It's not working. Is there anyway of put this callback with OOP?</p>
  
  <pre><code>ERROR MESSAGE: array_map() expects parameter 1 to be a valid callback, function 'this-&gt;id2area' not found or invalid function name
  </code></pre>
  
  <p>MY CODE
   =================================================================================</p>
  
  <pre><code>$this-&gt;context-&gt;assign('user_areas', implode(', ', array_map('id2area',   explode(',', $this-&gt;user['areas']))));     
  explode(',', $this-&gt;user['areas']))));
  
  
  
  function id2area($id) {//callback
      if ($id == 0) {
          return 'National';
      }
      $query = "SELECT area FROM area WHERE id = $id";
      return DB::fetch_instance()-&gt;slave-&gt;fetchColumn($query);
  }    
  </code></pre>