/* * 过滤数组中title的数据,其他不变 * $list为二维数组 Array( [0] => Array( [id] => 242 [location] => 2 [type] => 4 ) [1] => Array( [id] => 242 [location] => 2 [type] => 4 ) ) */ foreach ($list AS $k => $v) { while ($key = key($v)) { //$key为'title' if($key == 'title'){ $list[$k][$key] = trim(checkTextSpecification($v[$key])); }else{ $list[$k][$key] = trim($v[$key]); } //指针一定到下一个键,否则死循环 next($v); } }