$postField = 'user_name,password,passwordb,email';
$data = $this->request->only(explode(',',$postField),'post',null);
$data['user_name']=trim($data['user_name']); //去掉头尾空格
$data['user_name']=str_replace(' ','',$data['user_name']);//去掉中间有些空格。
主要用到:trim 和str_replace
也可以定义一个function()以便以后用。
====
function dellspace($str){
$str=trim($str);
$str=str_replace(' ','',$str);
return $str;
}