0

Possible Duplicate:
setting scope of array_map php

I have a function called cube1() in a class called customExceptions. In another PHP script I need to use array_map(), and for the callback function I want to use the cube1() function in the customExceptions class. What is the syntax to do this? This seems a really basic question but I could't find a simple straight forward answer.

Community
  • 1
  • 1
Les_Salantes
  • 317
  • 6
  • 20

2 Answers2

1
<?php

class customExceptions{    
    static public function cube1($i){
        return $i*$i*$i;
    }
}

$arr = array(1,2,3,4);
print_r($arr);
$arr2 = array_map(array('customExceptions', 'cube1'), $arr);
print_r($arr2);

?>
Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
0

Shouldn't this work?

customExceptions::cube1(array_map());
Connor Peet
  • 6,065
  • 3
  • 22
  • 32