Re: Finding a value in an array
| From: | Jon Rosenberg | Date: | Mon, 08 Jan 2001 21:33:36 +0000 |
| Subject: | Re: Finding a value in an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33322@lists.php.net to get a copy of this message | ||
in_array
in_array -- Return true if a value exists in an array
Description
bool in_array(mixed needle, array haystack);
Searches haystack for needle and returns true if it is found in the array,
false otherwise.
Example 1. in_array() example
1
2 $os = array ("Mac", "NT", "Irix", "Linux");
3 if (in_array ("Irix", $os))
4 print "Got Irix";
5
Note: This function was added in PHP 4.0.
-----------------------------------------------------------------
Jonathan Rosenberg
Be fierce, be fabulous, change the world!
----- Original Message -----
From: "Todd Cary" <todd@aristesoftware.com>
To: <php-general@lists.php.net>
Sent: Monday, January 08, 2001 4:28 PM
Subject: [PHP] Finding a value in an array
> Other than looping through an array, is there a Find function to see if
> a value is in an array?
>
> I need to add values to an array, but I want to check to see if the
> value is already in the array where the values are generated by the
> random number generator.
>
> Todd
>
> --
> Todd Cary
> Ariste Software
> todd@aristesoftware.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>