2
我有一个数组$ field。如何将一个函数添加到PHP中的数组中
注意:有人在标签中添加codeigniter,但问题本身就是关于PHP的。
通常以这种方式保存内容。
// SAVE FORM CONTENTS
foreach ($fields_to_show as $key=>$value) {
$this->CI->preference->set_item($key,$this->CI->input->post($key));
}
这是方法set_item()
function set_item($name, $value)
{
if (is_null($name)) {
return false;
}
$this->preferenceCache[$name] = $value;
if (is_array($value)) {
$value = $this->object_keyword . serialize($value);
}
$this->db->where('name', $name);
return $this->db->update(PREFERENCES, array('value'=>$value));
}
现在场之一是密码,所以我想编码。
的方法encode_password()工作正常(我在不同的类使用它),但是当我尝试以下,但不编码“ga_password”
// set ga_password
if ($this->CI->input->post('ga_password') != '') {
// Load userlib language
$this->CI->load->module_library('auth','userlib');
$fields_to_show['ga_password'] =
$this->CI->userlib->encode_password($this->CI->input->post('ga_password'));
}
// SAVE FORM CONTENTS
foreach ($fields_to_show as $key=>$value) {
$this->CI->preference->set_item($key,$this->CI->input->post($key));
}