Php错误:sizeof():参数必须是实现可计数的数组或对象
我得到了这个错误: 严重性:警告 Message:sizeof():参数必须是 可数的 文件名:controllers/Wallet.php 电话号码:91 第91行代码是:Php错误:sizeof():参数必须是实现可计数的数组或对象,php,codeigniter,Php,Codeigniter,我得到了这个错误: 严重性:警告 Message:sizeof():参数必须是 可数的 文件名:controllers/Wallet.php 电话号码:91 第91行代码是: if (sizeof($selected_int_array)>0) { foreach ($selected_int_array as $interest_code) { //get amount $interest_amount = $this->db->get
if (sizeof($selected_int_array)>0) {
foreach ($selected_int_array as $interest_code) {
//get amount
$interest_amount = $this->db->get_where('interests', array('userID' => $account_id, 'deleted !=' => 'yes', 'blocked !=' => 'yes', 'interest_code' => $interest_code, 'status' => 'available'))->row()->interest_amount;
$total_amount += $interest_amount;
$interests_involved='yes';
$codes_involved.= '+'.$interest_code;
}
}
如何解决此问题?Dump
$selected\u int\u array
。这显然不是一个数组。此变量来自何处?旁注:在执行foreach
之前,无需检查数组大小。如果一个数组是空的,它就不会被执行。因此,如果完全,您可以删除该。@El_Vanja$selected\u int\u array=$this->input->post('selected\u interest');转储时它包含什么?不能对任意内容使用sizeof()
sizeof([12,34])
显然是2
但是,例如大小(new Datetime())
应该是什么?Dump$selected\u int\u array
。这显然不是一个数组。此变量来自何处?旁注:在执行foreach
之前,无需检查数组大小。如果一个数组是空的,它就不会被执行。因此,如果
完全,您可以删除该。@El_Vanja$selected\u int\u array=$this->input->post('selected\u interest');转储时它包含什么?不能对任意内容使用sizeof()
sizeof([12,34])
显然是2
但是,例如size(new Datetime())
应该是什么?