With array_slice
, for example:
$levels = array_slice($levels, 0, count($images) - 1);
You should pay some attention to the arguments so that this works exactly how you want it to in edge cases as well (for example what happens if $images
is empty?)