note 53626 deleted from function.array-search by nlopess
| From: | nlopess@php.net | Date: | Tue, 07 Jun 2005 18:15:57 +0000 |
| Subject: | note 53626 deleted from function.array-search by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90079@lists.php.net to get a copy of this message | ||
Note Submitter: James Golick
----
<?php
$array = array( 0 => "value" );
if ( array_search( "value", $array ) )
{
echo "found";
}
else
{
echo "not found";
}
?>
The above will echo not found, because php accepts 0 to be the same as false.
The solution is as follows
<?php
function remove0(&$array)
{
$array[] = $array[0];
unset($array[0]);
}
?>
see my blog
http://phpmethods.blogspot.com
James