Well, I think the problem is, if that .htpasswd01 file is in the form of
user:cryptpassword
user1:cryptpassword
then when you search for "Martin" it looks for just that but in the array the value is "Martin:xxxxxxxxx"
If my theory is correct try the following code:
<?php
$array = file(".htpasswd01"); // get the file in an array
$tempArray = array(); //create an empty array for temp use
foreach($array as $line) { //iterate thru the array 1 line at a time
$name = explode(":",$line); //explode the line into 1 array
array_push($tempArray, $line[0]); //push first element to temp
}
//now we have just the names in an array w/ corresponding keys
$index = array_search("Martin",$tempArray); //search new array for the name
if($index !== NULL) { //we found a match
echo $array[$index]; //echo the value
} else { //no match
echo "Sorry, couldn't find Martin in the file";
}
?>
try that code, hopefully it will work, i havnt tested it.