3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr=array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,);$count=count($arr); foreach($arr as $key=>$value){ if($key%2==0){ unset($arr[$key]); $count--; } var_dump($arr); echo $count; if(1!=$count) continue; else echo $key; }
based on B1SXe
Output for 4.3.0 - 7.1.0
array(9) { [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 9array(8) { [1]=> int(1) [3]=> int(3) [4]=> int(4) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 8array(8) { [1]=> int(1) [3]=> int(3) [4]=> int(4) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 8array(7) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 7array(7) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 7array(6) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 6array(6) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [7]=> int(7) [8]=> int(8) [9]=> int(9) } 6array(5) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [7]=> int(7) [9]=> int(9) } 5array(5) { [1]=> int(1) [3]=> int(3) [5]=> int(5) [7]=> int(7) [9]=> int(9) } 5