title: php callback function in class
body: <p>for some reasons, our hosting company used PHP 5.2 and doesn't even have mysqli and PDO pre-installed.</p>
  
  <p>I have no choice but to rewrite some part of my code to make it 5.2 compatible.</p>
  
  <p>so, here is my question:</p>
  
  <p>In PHP 5.2 Anonymous function is not supported, so i did the following test to make sure I'm changing the code correctly:</p>
  
  <pre><code>class foo{
  
      public function toString(){
          $arr = array("a", "b");
          $arr2 = array("c", "d");
          print_r(array_map('mapKeyValue', $arr, $arr2));
      }
  
      private function mapKeyValue($v, $k){
          return $k."='".$v."'";
      }
  }
  
  $foo = new foo();
  echo $foo-&gt;toString();
  </code></pre>
  
  <p>but the above would give me :</p>
  
  <pre><code>Warning: array_map() expects parameter 1 to be a valid callback, function 'mapKeyValue' not found or invalid function name in ....
  PHP Warning: array_map() expects parameter 1 to be a valid callback, function 'mapKeyValue' not found or invalid function name in ....
  </code></pre>
  
  <p>what is the correct way to do :</p>
  
  <pre><code>array_map('mapKeyValue', $arr, $arr2);
  </code></pre>
  
  <p>within a class?</p>
  
  <p>PS: Is it a good enough reason to change hosting company because they use PHP 5.2?(i got a contract with about 7 month left)</p>