note 38667 added to function.in-array
| From: | gphemsley at users dot sourceforge dot net | Date: | Fri, 02 Jan 2004 04:18:20 +0000 |
| Subject: | note 38667 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62768@lists.php.net to get a copy of this message | ||
For those of you who need in_array() for PHP3, this function should do the trick.
<?php
function in_array( $needle, $haystack, $strict = FALSE )
{
@reset( $haystack );
while( @list( , $value ) = @each( $haystack ) )
{
if( $needle == $value )
{
if( $strict && ( gettype( $needle ) != gettype( $value ) ) )
{
return FALSE;
}
else
{
return TRUE;
}
}
}
return FALSE;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38667
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38667&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38667&report=yes
Search -- http://master.php.net/manage/user-notes.php