3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = ['one', 'two', 'three', 'four',]; $result = []; $temp = &$arr; foreach($arr as $v){ $temp[$v] = $arr; $result = $temp; } print_r($result);
based on CEF5R
Output for 7.0.0 - 7.2.0
Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array *RECURSION* ) [four] => Array *RECURSION* )
Output for 5.4.2 - 5.6.28
Warning: Illegal offset type in /in/DA1Z8 on line 9 Warning: Illegal offset type in /in/DA1Z8 on line 9 Warning: Illegal offset type in /in/DA1Z8 on line 9 Warning: Illegal offset type in /in/DA1Z8 on line 9 Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array *RECURSION* ) [four] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array ( [0] => one [1] => two [2] => three [3] => four [one] => Array *RECURSION* ) [two] => Array *RECURSION* ) [three] => Array *RECURSION* ) [four] => Array *RECURSION* ) )
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/DA1Z8 on line 3
Process exited with code 255.