3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = ["a", "b", "c"]; foreach($a as $key => &$value) { var_dump($key, $value); if($value !== "Test") array_splice($a, $key, 1, ["Test", "Test2"]); var_dump($a); if(count($a) > 6) exit; }
Output for 7.0.0 - 7.2.0
int(0) string(1) "a" array(4) { [0]=> string(4) "Test" [1]=> string(5) "Test2" [2]=> string(1) "b" [3]=> string(1) "c" } int(3) string(1) "c" array(5) { [0]=> string(4) "Test" [1]=> string(5) "Test2" [2]=> string(1) "b" [3]=> string(4) "Test" [4]=> string(5) "Test2" }
Output for 5.5.0 - 5.6.30, hhvm-3.10.1 - 3.17.3
int(0) string(1) "a" array(4) { [0]=> string(4) "Test" [1]=> string(5) "Test2" [2]=> string(1) "b" [3]=> string(1) "c" } int(0) string(4) "Test" array(4) { [0]=> &string(4) "Test" [1]=> string(5) "Test2" [2]=> string(1) "b" [3]=> string(1) "c" } int(1) string(5) "Test2" array(5) { [0]=> string(4) "Test" [1]=> string(4) "Test" [2]=> string(5) "Test2" [3]=> string(1) "b" [4]=> string(1) "c" } int(0) string(4) "Test" array(5) { [0]=> &string(4) "Test" [1]=> string(4) "Test" [2]=> string(5) "Test2" [3]=> string(1) "b" [4]=> string(1) "c" } int(1) string(4) "Test" array(5) { [0]=> string(4) "Test" [1]=> &string(4) "Test" [2]=> string(5) "Test2" [3]=> string(1) "b" [4]=> string(1) "c" } int(2) string(5) "Test2" array(6) { [0]=> string(4) "Test" [1]=> string(4) "Test" [2]=> string(4) "Test" [3]=> string(5) "Test2" [4]=> string(1) "b" [5]=> string(1) "c" } int(0) string(4) "Test" array(6) { [0]=> &string(4) "Test" [1]=> string(4) "Test" [2]=> string(4) "Test" [3]=> string(5) "Test2" [4]=> string(1) "b" [5]=> string(1) "c" } int(1) string(4) "Test" array(6) { [0]=> string(4) "Test" [1]=> &string(4) "Test" [2]=> string(4) "Test" [3]=> string(5) "Test2" [4]=> string(1) "b" [5]=> string(1) "c" } int(2) string(4) "Test" array(6) { [0]=> string(4) "Test" [1]=> string(4) "Test" [2]=> &string(4) "Test" [3]=> string(5) "Test2" [4]=> string(1) "b" [5]=> string(1) "c" } int(3) string(5) "Test2" array(7) { [0]=> string(4) "Test" [1]=> string(4) "Test" [2]=> string(4) "Test" [3]=> string(4) "Test" [4]=> string(5) "Test2" [5]=> string(1) "b" [6]=> string(1) "c" }