小编ani*_*k4e的帖子

PHP - 修剪数组元素值而不用foreach

我在php中使用以下代码:代码:

$input = array("     text1","text2      "," text3       ","     text4");
$output = array();
foreach($input as $val)
     {
        $output[] = trim($val);
     }
var_dump($output);
Run Code Online (Sandbox Code Playgroud)

是否可以在没有foreach循环的情况下修剪数组元素值?

php arrays

3
推荐指数
1
解决办法
1227
查看次数

标签 统计

arrays ×1

php ×1