3v4l.org

run code in 300+ PHP versions simultaneously
<?php $front = ["front_first", "front_second"]; $inside = ["inside_first", "inside_second", "inside_third"]; $back = ["back_first", "back_second", "back_third", "back_fourth"]; var_export( array_merge( ...array_map( function(...$cols) { static $lastSet; foreach ($cols as $i => &$v) { $v ??= $lastSet[$i]; } $lastSet = $cols; return $cols; }, $back, $front, $inside ) ) );

preferences:
27.04 ms | 406 KiB | 5 Q