If you are using the result of array_search in a condition statement, make sure you use the === operator instead of == to test whether or not it found a match. Otherwise, searching through an array with numeric indicies will result in index 0 always getting evaluated as false/null. This nuance cost me a lot of time and sanity, so I hope this helps someone. In case you don't know what I'm talking about, here's an example:
<?php
$code = array("a", "b", "a", "c", "a", "b", "b"); while (($key = array_search("a", $code)) != NULL)
{
unset($code[$key]);
}
while (($key = array_search("a", $code)) !== NULL)
{
unset($code[$key]);
}
?>