How to stripslashes all the items of an array at once?

前端 未结 6 1315
面向向阳花
面向向阳花 2021-01-17 18:36

I need to stripslashes all items of an array at once.

Any idea how can I do this?

6条回答
  •  广开言路
    2021-01-17 19:14

    Any recursive function for array :

    $result= Recursiver_of_Array($array, 'stripslashes');

    code:

    function Recursiver_of_Array($array,$function_name=false){ 
      //on first run, we define the desired function name to be executed on values
        if ($function_name) { $GLOBALS['current_func_name']= $function_name; } else {$function_name=$GLOBALS['current_func_name'];}
      //now, if it's array, then recurse, otherwise execute function
        return is_array($array) ? array_map('Recursiver_of_Array', $array) : $function_name($array); 
    }
    

提交回复
热议问题