I have a PHP array, say,
$array = Array("Name1","Name2","Name3","Name4","Name5");
I want to find the position of these names in the array.
I want to return 0 for Name1 and 2 for Name3.
How can I do this?
$pos = array_search("Name3", $array);
Should be what you are looking for, note that to be safe, result checking should be using === (three equal signs) so that those returning 0 (if you are looking for thing in the first element) is also checked for type when you are comparing them in an if statement
if(array_search($name, $array) === 0)
array_search. BTW have you ever tried to look at ru2.php.net/manual/en/ref.array.php ?