> Say I'm trying to add a value to an array, only if it's not already in
> there somewhere; so I do an array_search to see. The problem is that if
> the item is at index 0 in the array, array_search gives the same answer
> as if it's not in there at all. How does one circumvent this potential
> pitfall?

I think this would work (I could be wrong)

$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

if(($key = array_search('bluesf', $array)) !== FALSE) {
        echo $key;
}

if(($key = array_search('blue', $array)) !== FALSE) {
        echo $key;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to