0
以我CakePHP的控制器有一個名爲saveReport()
一個動作,其中$attribute_ids
是一個數組保持從Ajax的交獲得的所有選定的屬性..查找陣列長度incakephp
function saveReport()
{
echo $this->params['form']['formid'];
echo $this->params['form']['reportTitle'];
echo $this->params['form']['attr'];
$attribute_ids=$this->params['form']['attr'];
$comma_separated = explode(",", $attribute_ids);
for($i=0;$i<15;$i++)
{
echo $comma_separated[$i];
echo " ";
$this->data['Report']['title']=$this->params['form']['reportTitle'];
$this->data['Report']['form_id']=$this->params['form']['formid'];
$this->data['Report']['attr_id']=$comma_separated[$i];
$this->Report->saveAll($this->data);
}
}
如何識別$comma_separated
的長度,其中$comma_separated
是一個數組,因此我可以在for循環中使用它,現在我默認使用它作爲15 ...
+1帕斯卡爾又名PHP的人;) – 2009-09-14 04:48:09