我不确定为什么以下不起作用。我收到上述错误(主题):
$array = array (); //something goes in here
function del_space(array $a){
foreach($a as $key => $value){
preg_replace("/; +/", "", $value);
}
}
$no_space = array_map("del_space", $array);
最佳答案
array_map()
为您循环 $array
,因此我假设 $array
中的每个项目都不是数组对象但是 del_space()
需要向其传递一个数组。
听起来你有:
$array = array( 'some item' ); // Fails
但是你需要这样的东西:
$array = array( array( 'some item' ) ); // Success
如果您想使用array_map()
关于php - array_map - "Argument passed must be of the type array, string given"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50842858/