I like that chose 42 for the value.  You win, and I completely agree.

On Wed, Aug 15, 2012 at 4:22 PM, Stas Malyshev <smalys...@sugarcrm.com>wrote:

> Hi!
>
> > How come there is no straight-foward obvious way to simply remove a given
> > value from an array?
>
> The same reason there's no simple way to undefine variable whose value
> is 42 without knowing the variable name. Array is a container indexed by
> keys, not values. So if you've got just a value, there's no way to know
> if it's in the container at all, and if it is, where it is, except for
> going through all the values and checking if any of them is equal to
> what you nedd.
>
> > Just look at the number of horrible ways people solve this obvious
> problem:
>
> I see:
> if(($key = array_search($del_val, $messages)) !== false) {
>     unset($messages[$key]);
> }
>
> Nothing horrible here.
>
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to