array_map not working in classes

后端 未结 4 1144
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 01:00

I am trying to create a class to handle arrays but I can\'t seem to get array_map() to work in it.



        
4条回答
  •  情话喂你
    2020-12-24 01:40

    You are specifying dash as the callback in the wrong way.

    This does not work:

    $this->classarray = array_map($this->dash(), $data);
    

    This does:

    $this->classarray = array_map(array($this, 'dash'), $data);
    

    Read about the different forms a callback may take here.

提交回复
热议问题