hi I need to read a text file and then explode it to two piece then match it with give name then dispay if it matches...so far the code I made is given below..but it doesnt work..can any one tell me what wrong is with this code??
$name = "thomas";
$filename = file("land.txt");
//$contents = fread($handle, filesize($filename));
for($i=0; $i<count($filename); $i++)
{
$string = explode(":", $filename[$i]);
if($name == $string[1])
$id = $string[0];
}
echo $id;
this case it should display "D1"; but it doesnt!!
content of "land.txt"
file
D1:thomas
D6:benny
D7:alwyn
D25:mathew
D9:peter