<?php class Test{ public function trimArray($params){ if (!is_array($params)) return trim($params); return array_map([__CLASS__,'trimArray'], $params); }} $test = new Test();$arr = [' s',' sfsdfsdf'];var_dump($arr);$res = $test->trimArray($arr);var_…
CharSequence就是字符序列,String, StringBuilder和StringBuffer都是其实现类. 模仿String.trim() 实现了一个CharSequence通用的去除两端空格方法. public static CharSequence trim(CharSequence cs) { int len = cs.length(); int st = 0; while ((st < len) && (cs.charAt(st) <= ' ')) { s…