I read a textbook and it said each() function is deprecated. The author has recommend his own replacement for each() function called myEach() as following:
function myEach(&$array)
{
$key = key($array);
$result = ($key === null) ? false :
[$key, current($array), 'key', 'value' => current($array)];
next($array);
return $result;
}
Is the part: [$key, current($array), 'key', 'value' => current($array)];
wrong?
CodePudding user response:
The author is correct as each
is deprecated : https://www.php.net/manual/en/function.each.php
The 3rd argument is wrong, it should be key => $key
[$key, current($array), 'key' => $key, 'value' => current($array)];