setting scope of array_map php

前端 未结 3 1180
情话喂你
情话喂你 2021-01-14 16:31

hey all, i use array_map from time to time to write recursive methods. for example

function stripSlashesRecursive( $value ){

    $value = is_array($value) ?         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 17:01

    array_map takes a callback as its first parameter.

    And a callback to a static method is written like this :

    array('classname', 'methodname')
    


    Which means that, in your specific case, you'd use :

    array_map(array('stripSlashesRecursive', ''), $value);
    


    For more informations about callbacks, see this section of the PHP manual : Pseudo-types and variables used in this documentation - callback.

提交回复
热议问题