melissa820
02-04-2005, 07:53 PM
I was wondering if there is a function to do this. I want to find out if a certain string is in an array and if it is there, what index (key) is it at.
What I need is a way to get the index (1 in the example case below).
Basically it is just because I want to do an 'unset' on it (remove it from the array) if it is there.
Eg. :
$myArray = array( 0 => "Dog",
1 => "Cat",
2 => "Bird");
//the in_array function returns true here:
$isThere = in_array("Cat", $myArray);
What I need is a way to get the index (1 in the example case below).
Basically it is just because I want to do an 'unset' on it (remove it from the array) if it is there.
Eg. :
$myArray = array( 0 => "Dog",
1 => "Cat",
2 => "Bird");
//the in_array function returns true here:
$isThere = in_array("Cat", $myArray);