CosmosRP Posted December 3, 2010 Share Posted December 3, 2010 Hey guys. How do you remove a specific element from an array? Lets say I have a string like this: $list = "guy,girl,boy,man,woman,lady"; Then I use explode to break it up into an array by commas: $listArray = explode(",",$list); Now $listArray contains everything. Now if I wanted to delete something specific from that array, how would I do that? So for example, I want to delete "man" out of the array. How do I do that without know its key? Link to comment https://forums.phpfreaks.com/topic/220529-removing-something-specific-from-an-array/ Share on other sites More sharing options...
btherl Posted December 3, 2010 Share Posted December 3, 2010 This function will give you the key: http://au2.php.net/manual/en/function.array-search.php array_filter() will let you use a callback to implement more complex filters on arrays. Link to comment https://forums.phpfreaks.com/topic/220529-removing-something-specific-from-an-array/#findComment-1142464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.