3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(1,2,3,4,5,6,7,8,9); foreach($arr as $key=>$value) { unset($arr[$key + 1]); echo $value . "\n"; echo "key=" . $key . ", value=" . $value . ", key+1=" . ($key+1) . ", arr[key+1]=" . $arr[$key + 1] . "\n\n"; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
1 Warning: Undefined array key 1 in /in/5auso on line 9 key=0, value=1, key+1=1, arr[key+1]= 2 Warning: Undefined array key 2 in /in/5auso on line 9 key=1, value=2, key+1=2, arr[key+1]= 3 Warning: Undefined array key 3 in /in/5auso on line 9 key=2, value=3, key+1=3, arr[key+1]= 4 Warning: Undefined array key 4 in /in/5auso on line 9 key=3, value=4, key+1=4, arr[key+1]= 5 Warning: Undefined array key 5 in /in/5auso on line 9 key=4, value=5, key+1=5, arr[key+1]= 6 Warning: Undefined array key 6 in /in/5auso on line 9 key=5, value=6, key+1=6, arr[key+1]= 7 Warning: Undefined array key 7 in /in/5auso on line 9 key=6, value=7, key+1=7, arr[key+1]= 8 Warning: Undefined array key 8 in /in/5auso on line 9 key=7, value=8, key+1=8, arr[key+1]= 9 Warning: Undefined array key 9 in /in/5auso on line 9 key=8, value=9, key+1=9, arr[key+1]=
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
1 Notice: Undefined offset: 1 in /in/5auso on line 9 key=0, value=1, key+1=1, arr[key+1]= 2 Notice: Undefined offset: 2 in /in/5auso on line 9 key=1, value=2, key+1=2, arr[key+1]= 3 Notice: Undefined offset: 3 in /in/5auso on line 9 key=2, value=3, key+1=3, arr[key+1]= 4 Notice: Undefined offset: 4 in /in/5auso on line 9 key=3, value=4, key+1=4, arr[key+1]= 5 Notice: Undefined offset: 5 in /in/5auso on line 9 key=4, value=5, key+1=5, arr[key+1]= 6 Notice: Undefined offset: 6 in /in/5auso on line 9 key=5, value=6, key+1=6, arr[key+1]= 7 Notice: Undefined offset: 7 in /in/5auso on line 9 key=6, value=7, key+1=7, arr[key+1]= 8 Notice: Undefined offset: 8 in /in/5auso on line 9 key=7, value=8, key+1=8, arr[key+1]= 9 Notice: Undefined offset: 9 in /in/5auso on line 9 key=8, value=9, key+1=9, arr[key+1]=
Output for 7.3.32 - 7.3.33
1 key=0, value=1, key+1=1, arr[key+1]= 2 key=1, value=2, key+1=2, arr[key+1]= 3 key=2, value=3, key+1=3, arr[key+1]= 4 key=3, value=4, key+1=4, arr[key+1]= 5 key=4, value=5, key+1=5, arr[key+1]= 6 key=5, value=6, key+1=6, arr[key+1]= 7 key=6, value=7, key+1=7, arr[key+1]= 8 key=7, value=8, key+1=8, arr[key+1]= 9 key=8, value=9, key+1=9, arr[key+1]=
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
1 Notice: Undefined offset: 1 in /in/5auso on line 9 key=0, value=1, key+1=1, arr[key+1]= 2 Notice: Undefined offset: 2 in /in/5auso on line 9 key=1, value=2, key+1=2, arr[key+1]= 3 Notice: Undefined offset: 3 in /in/5auso on line 9 key=2, value=3, key+1=3, arr[key+1]= 4 Notice: Undefined offset: 4 in /in/5auso on line 9 key=3, value=4, key+1=4, arr[key+1]= 5 Notice: Undefined offset: 5 in /in/5auso on line 9 key=4, value=5, key+1=5, arr[key+1]= 6 Notice: Undefined offset: 6 in /in/5auso on line 9 key=5, value=6, key+1=6, arr[key+1]= 7 Notice: Undefined offset: 7 in /in/5auso on line 9 key=6, value=7, key+1=7, arr[key+1]= 8 Notice: Undefined offset: 8 in /in/5auso on line 9 key=7, value=8, key+1=8, arr[key+1]= 9 Notice: Undefined offset: 9 in /in/5auso on line 9 key=8, value=9, key+1=9, arr[key+1]=

preferences:
297.67 ms | 404 KiB | 462 Q