Laravel - Collections - Method Pop

The pop method removes and returns the last item from the collection:

    
    $collection = collect([1, 2, 3, 4, 5]);
    
    $collection->pop();
    
    // 5
    
    $collection->all();
    
    // [1, 2, 3, 4]
	

You may pass an integer to the pop method to remove and return multiple items from the end of a collection:

    
    $collection = collect([1, 2, 3, 4, 5]);
    
    $collection->pop(3);
    
    // collect([5, 4, 3])
    
    $collection->all();
    
    // [1, 2]