我有
if ( is_array($this->input->post("tolerance")) )
foreach($this->input->post("tolerance") as $tolerance)
$tolerances .= $tolerance . " " ;
else
$tolerances = 'Not defined';
我想缩短代码,因为我们都知道我们在获取数组值之前验证它是否是一个数组
那么缩短这个的正确方法是什么?
is_array($this->input->post("tolerance")) ? foreach($this->input->post("tolerance") as tolerance) $tolerances .= $tolerance . " " : $tolerances = 'Not defined';