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? Quote 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. Quote 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. Quote 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. Quote 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. :) Quote Link to comment https://forums.phpfreaks.com/topic/31131-solved-quick-array-question/#findComment-143771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.