Forum Moderators: coopster
What i basically want to do is use IF to see if my variable appears in group of strings.
For Example to find out whether Yellow appears in the following list:
Black
Blue
Red
Brown
Green
My initial though is an array of strings, but I am a bit unsure of how to do this.
Any help would be appreciated
Thanks Chris
<?
// create an array of strings called $colours:
$colours = array( "Black", "Orange", "Red", "Brown", "Green" );
// use the in_array() function to check if "Yellow" is in the array:
if( in_array("Yellow", $colours) )
{
echo "Yellow is in the array";
}
else
{
echo "Yellow isn't in the array";
}
?>