On 08/17/2012 05:21 PM, Rasmus Schultz wrote: >> >> if(($key = array_search($del_val, $messages)) !== false) { >> unset($messages[$key]); >> } >> >> Nothing horrible here. >> > > I disagree - this is (or should be) a simple, atomic operation... > yet, you've got a function-call, an intermediary variable, a boolean test, > and an unset statement repeating the name of the array you're deleting from. > > This should be a simple statement or function/method-call, and in most > other languages it would be...
Really? I can't think of a single language that has a call to remove an element by value in a key-value hash. Do you have some examples? What do you do with duplicates? -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php