可以在函数参数中传递数组吗?例如,将数组传递给函数参数
function something()
{
if ($this->db->insert($this->table_name, $data)) {
$data = array(
'user_id' => $this->db->insert_id();
'first_name' => $this->form_validation->set_value('first_name'),
'last_name' => $this->form_validation->set_value('last_name'),
);
if ($activated)
$this->create_profile($data);
return array(//not sure why i'm returning this
'user_id' => $user_id,
'first_name' => $first_name,
'last_name' => $last_name,
} );
return NULL;
}
,然后传递到
private function create_profile($data)
{
return $this->db->insert($this->profile_table_name, $data)
}
剧本是从我修改了一个笨的插件,所以我想不杀猪太多。
为什么不....... – Dani 2011-05-25 02:42:08
,因为我还没有完全理解它:( – CyberJunkie 2011-05-25 02:45:39
当你所有的代码工作,你想要的方式?现在,在返回数组中有一些奇怪的花括号('并且可能在'if($ activated)'之后缺少'{'),我开始执行这个操作。编辑自己,但意图是不清楚在哪里缺少'{'是。 – 2011-05-25 02:59:21