KevinM1 Posted December 18, 2006 Share Posted December 18, 2006 Is there a function that removes/deletes an item from an array, returning the newly reduced array and not the element that was removed/deleted? Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/ Share on other sites More sharing options...
Orio Posted December 18, 2006 Share Posted December 18, 2006 Do you want to delete a cell from an array by a given [b]key[/b] or [b]value[/b]?If it's by key, just use the [url=http://www.php.net/manual/en/function.unset.php]unset()[/url] function. Example: unset($array['remove_me']);If it's by value, use [url=http://www.php.net/manual/en/function.array-search.php]array_search()[/url] first, and then unset().Orio.Orio. Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/#findComment-143754 Share on other sites More sharing options...
KevinM1 Posted December 18, 2006 Author Share Posted December 18, 2006 Will the unset array elements be physically removed from the array, or merely turned into null values? I ask because I plan on using a foreach on the modified array after the proper elements are removed, and thus I don't want to have any null-value gaps in the datastructure. Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/#findComment-143759 Share on other sites More sharing options...
Orio Posted December 18, 2006 Share Posted December 18, 2006 Removed :)Orio. Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/#findComment-143769 Share on other sites More sharing options...
KevinM1 Posted December 18, 2006 Author Share Posted December 18, 2006 [quote author=Orio link=topic=119139.msg487489#msg487489 date=1166465137]Removed :)Orio.[/quote]Sweet, thanks. :) Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/#findComment-143771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.