Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Add sliceConsecutive($size) method to Collection #20985

Closed

Conversation

slava-vishnyakov
Copy link
Contributor

The method returns each consecutive slice of fixed size, like this:

$data = new Collection([1, 2, 3, 4, 5]);
$data->sliceConsecutive(3)

[ [1, 2, 3], [2, 3, 4], [3, 4, 5] ]

$data->sliceConsecutive(5) // or 6 and more

[ [1, 2, 3, 4, 5] ]

$data->sliceConsecutive(0)

[  ]

Note: Collections are replaced with arrays for brevity

The method returns each consecutive slice of fixed size, like this:

        $data = new Collection([1, 2, 3, 4, 5]);
        $data->sliceConsecutive(3)

        [ [1, 2, 3], [2, 3, 4], [3, 4, 5] ]

Collections replaced with arrays for brevity
@taylorotwell
Copy link
Member

No plans to add. macro it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants