$model->attributes = array_filter(Yii::$app->request->post()
<?php
$arr=array(0,'linux',123,'hello',false,array(),'0');
$rst=array_filter($arr);
echo '<pre>';
print_r($rst);
echo '</pre>';
//输出的结果是:
/*
Array
(
[1] => linux
[2] => 123
[3] => hello
)
*/
//用于赋值的时候,清除前端转过来的表单中的空值
?>