I have this code:
$hackers = array ('Alan Kay', 'Peter Norvig', 'Linus Trovalds', 'Larry Page');
I want to delete 1st two items and later want to get back just deleted items in an array
I have this code:
$hackers = array ('Alan Kay', 'Peter Norvig', 'Linus Trovalds', 'Larry Page');
I want to delete 1st two items and later want to get back just deleted items in an array
Use array_splice()
. It returns an array of the elements that it removed:
$first_two = array_splice($hackers, 0, 2);