php trim array

2012-09-07   来源:站长日记       编辑:沧海桑田   类别:PHP 教程    转载到:    发表评论

function trim_r($arr)
{
return is_array($arr) ? array_map('trim_r', $arr) : trim($arr);
}

very helpful.
However, instead of creating a new function, you could just use the trim function as the callback for array_map, for example:

array_map('trim', $arr);

array_map — Applies the callback to the elements of the given arrays

Report a bug Description
array array_map ( callable $callback , array $arr1 [, array $... ] )
array_map() returns an array containing all the elements of arr1 after applying the callback function to each one. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()

Report a bug Parameters

callback
Callback function to run for each element in each array.

arr1
An array to run through the callback function.

array
Variable list of array arguments to run through the callback function.

0

0
0|0 | 鲜花 VS 砸蛋 | 19阅读 0评论
上一篇: 取SEO文件名
下一篇: information 分类