How to alter the function of php 5x php 7.2?

Hello. There is such a function:
$kv = each($mixed);
 // option flag?
 if (in_array($kv['key'], $this->option_flags)) {
 if (is_bool($kv['value'])) {
 $_indexed_attr[$kv['key']] = $kv['value'];
 } elseif (is_string($kv['value']) && in_array(trim($kv['value'], '\'"'), array('true', 'false'))) {
 if (trim($kv['value']) == 'true') {
 $_indexed_attr[$kv['key']] = true;
 } else {
 $_indexed_attr[$kv['key']] = false;
}
 } elseif (is_numeric($kv['value']) && in_array($kv['value'], array(0, 1))) {
 if ($kv['value'] == 1) {
 $_indexed_attr[$kv['key']] = true;
 } else {
 $_indexed_attr[$kv['key']] = false;
}
 } else {
 $compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", $compiler->lex->taglineno);
}
 // must be named attribute
 } else {
reset($mixed);
 $_indexed_attr[key($mixed)] = $mixed[key($mixed)];
 }


Conditionally on $kv = each($mixed);

How in 7.2 remake?
March 19th 20 at 08:32
3 answers
March 19th 20 at 08:34
foreach ($mixed as $kv) { ...
More precisely, like so:
foreach ($mixed as $k => $v) { ...
In this case, $k gets the key of $v value - Eliane commented on March 19th 20 at 08:37
According to the code values there are in $kv['key'] and $kv['value']. - Marisa commented on March 19th 20 at 08:40
March 19th 20 at 08:36
and 5 isn't cursed? see the list of reserved words
March 19th 20 at 08:38
$kv = [key($mixed), current($mixed)];
next($mixed);

Find more questions by tags PHP