3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['one', 'two', 'three', 'four',]; $result = []; $temp = &$arr; foreach($arr as $v){ $temp[$v] = $arr; $result = $temp; } print_r($result);

preferences:
57.14 ms | 402 KiB | 5 Q