Skip to content

Instantly share code, notes, and snippets.

@hotmeteor
Last active May 23, 2016 20:19
Show Gist options
  • Save hotmeteor/a098df67ed12d922ced7a3fddaae98d0 to your computer and use it in GitHub Desktop.
Save hotmeteor/a098df67ed12d922ced7a3fddaae98d0 to your computer and use it in GitHub Desktop.
Insert record into a collection at a specific index
<?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