<?php

$array = [5, 6, 7, 8];

for ($i = count($array) - 1; $i >= 0; $i--) {
    $result = empty($result) ? [$array[$i]] : [$array[$i], $result];
}

var_export($result);
