
* 数组中所有元素都用小写字母,并按照字母先后次序排序
class sort {
private $str;
public function __construct($str) {
$this->str=strtolower($str);
}
private function explodes() {
if(empty($this->str)) return array();
$arr=explode(" ",$this->str);
return is_array($arr)?$arr:array($arr);
}
public function sort() {
$explode=$this->explodes();
sort($explode);
return $explode;
}
}
$str='Apple Orange Banana Strawberry';
$sortob=new sort($str);
var_dump($sortob->sort());