I recently came across something of the form:
$allowed=array('foo','bar','baz');
foreach($stuff as $key => $value){
if( array_search( $key ,$allowed ) ){
What they meant was:
$allowed=array('foo','bar','baz');
foreach($stuff as $key => $value){
if( in_array( $key ,$allowed ) ){
I hate all the PHP array functions, partly because there are so many and I don’t recall many of them, and partly because that is the case with everyone else and they still use them. The first entry in the array will have a key of 0 which php will evaluate to false. Who really cares about foo anyways…