Warning: count(): Parameter must be an array or an object that implements Countable Deprecated: The each() function is deprecated. This message will be suppressed on further calls
这两函数在php7.2,7.3开始出现兼容问题, 为了更好的支持函数调用. 我们需要重写这两个函数.
function fun_each(&$array){
$res = array();
$key = key($array);
if($key !== null){
next($array);
$res[1] = $res['value'] = $array[$key];
$res[0] = $res['key'] = $key;
}else{
$res = false;
}
return $res;
}
function fun_count($array_or_countable,$mode = COUNT_NORMAL){
$res = 0;
if(is_array($array_or_countable) || is_object($array_or_countable)){
$res = count($array_or_countable, $mode);
}
return $res;
}
使用方法跟旧函数一模一样, 本次解决方案目的是为了让过程不报错而已. 参考一下吧.