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; } print_r($arr); print_r($temp);
based on YsJa5
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* ) 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.8 - 5.6.28
Warning: Illegal offset type in /in/U8rsr on line 9 Warning: Illegal offset type in /in/U8rsr on line 9 Warning: Illegal offset type in /in/U8rsr on line 9 Warning: Illegal offset type in /in/U8rsr 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* ) ) 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/U8rsr on line 3
Process exited with code 255.