请问怎么去掉数组里面所有值两边的空格

WBOY
Release: 2016-06-23 13:18:41
Original
1387 people have browsed it

请问怎么去掉数组里面所有值两边的空格?
数组可能是一维也可能是二维数组


回复讨论(解决方案)

trim()

$a = array(  ' a', ' b ', 'c ',  array(' a', ' b ', array(' a', ' b ', 'c '),),);array_walk_recursive($a, function(&$v) { $v = trim($v); });var_export($a);
Copy after login
array (  0 => 'a',  1 => 'b',  2 => 'c',  3 =>   array (    0 => 'a',    1 => 'b',    2 =>     array (      0 => 'a',      1 => 'b',      2 => 'c',    ),  ),)
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template