php7.2 waste alternatives to each method

In the 7.2 version will prompt obsolete, you can use foreach replace each method, you can also modify their own each alternative method:

function func_new_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;
}

Guess you like

Origin www.cnblogs.com/njccqx/p/11772388.html