php用array_map给数组中的每个元素前面加字符串
$arr=[0,1,2,3];
$newArr = array_map(function ($value){
return 'str_'.$value;
},$arr);
$newArr就变成了['str_0','str_1','str_2','str_3']
$arr=[0,1,2,3];
$newArr = array_map(function ($value){
return 'str_'.$value;
},$arr);
$newArr就变成了['str_0','str_1','str_2','str_3']
评论已关闭