3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '17' => "x", '16' => "x", '15' => "x", '14' => "108.7000", '13' => "x", '12' => "x", '11' => "x", '10' => "x", '09' => "108.2635", '08' => "x", '07' => "x", '06' => "x", '05' => "x", '04' => "x", '03' => "x", '02' => "x", '01' => "x", '00' => "x", '23' => "x", '22' => "x", '21' => "x", '20' => "x", '19' => "x", '18' => "x" ]; foreach ($array as $k => $v) { if ($v === 'x') { $array[$k] =& $ref; } else { if (isset($ref)) { unset($ref); } $ref = $v; } } var_export($array);

preferences:
58 ms | 404 KiB | 5 Q