Last active
May 23, 2016 20:19
-
-
Save hotmeteor/a098df67ed12d922ced7a3fddaae98d0 to your computer and use it in GitHub Desktop.
Insert record into a collection at a specific index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$collection = collect([ 'red', 'blue' ]); | |
$collection->splice(1, 0, ['yellow']); | |
$collection->all(); | |
// ['red', 'yellow', 'blue']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment