Easy way to apply a function to an array

前端 未结 7 792
無奈伤痛
無奈伤痛 2020-12-03 14:31

I am aware of array_walk() and array_map(). However when using the former like so (on an old project) it failed

array_walk($_POST,          


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-03 14:43

    PHP 7.4 style:

    $link = mysqli_connect("localhost", "my_user", "my_password", "world");
    
    array_map(fn($string) => mysqli_real_escape_string($string, $link), $_POST);
    

提交回复
热议问题