3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); echo "Testing case 1\n"; foreach ($array as $key => $value) { unset($aarray[$kkey+1]); echo sprintf("on %s, we removed %s\n, current size is %d", $key, $key+1, count($array)); } echo "Testing case 2\n"; foreach ((array) $array as $key => $value) { unset($aarray[$key+1]); echo sprintf("on %s, we removed %s\n, current size is %d", $key, $key+1, count($array)); }
based on F7E5s
Output for 5.0.4 - 7.3.0beta1
Testing case 1 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 0, we removed 1 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 1, we removed 2 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 2, we removed 3 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 3, we removed 4 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 4, we removed 5 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 5, we removed 6 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 6, we removed 7 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 7, we removed 8 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 8, we removed 9 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 9, we removed 10 , current size is 10Testing case 2 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 0, we removed 1 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 1, we removed 2 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 2, we removed 3 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 3, we removed 4 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 4, we removed 5 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 5, we removed 6 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 6, we removed 7 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 7, we removed 8 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 8, we removed 9 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 9, we removed 10 , current size is 10
Output for 4.3.0 - 5.0.3
Testing case 1 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 0, we removed 1 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 1, we removed 2 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 2, we removed 3 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 3, we removed 4 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 4, we removed 5 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 5, we removed 6 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 6, we removed 7 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 7, we removed 8 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 8, we removed 9 , current size is 10 Notice: Undefined variable: kkey in /in/7JUOp on line 8 Notice: Undefined variable: aarray in /in/7JUOp on line 8 on 9, we removed 10 , current size is 10Testing case 2 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 0, we removed 1 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 1, we removed 2 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 2, we removed 3 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 3, we removed 4 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 4, we removed 5 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 5, we removed 6 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 6, we removed 7 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 7, we removed 8 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 8, we removed 9 , current size is 10 Notice: Undefined variable: aarray in /in/7JUOp on line 15 on 9, we removed 10 , current size is 10