On 2012-08-16 17:55, Sherif Ramadan wrote:
> That doesn't make any sense. What if the values are present more than
> once? array_flip will cause the keys to be overwritten.
>
Not to mention converting all of the array's elements to strings and/or integers.


Now your array is something completely different from what you wanted.
The solution stated earlier is the most sane one (just using
array_keys() with a search value).

The problem isn't very complicated and doesn't require a complex solution.

This thread is overstating a rudimentary problem (and that's the lack
of understanding PHP arrays).

I was actually alluding to something more disturbing:
<?php
$array = [['foo', 'bar'], ['wibble', 'fnord']];

$array = array_diff($array, [['wibble', 'fnord']]);

print_r($array);
?>
...which makes array_diff and its ilk only useful for scalar elements (hence the need for the more complicated approach using array_keys(), which provides a strictness flag).



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to