meszaros-lajos-gyorgy / shovel

A PHP library for manipulating Arrays, Strings and Objects - inspired by ramda.js
0 stars 0 forks source link

A::slice() should work with negative indices #14

Closed meszaros-lajos-gyorgy closed 3 years ago

meszaros-lajos-gyorgy commented 3 years ago

The internally used array_slice has this feature and seems to work correctly:

<?php

$data = [1, 2, 3, 4, 5];

echo '<pre>';

print_r(array_slice($data, 0, -2));

http://phptester.net/ displays the following as output for php 7.0 and above:

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)