strcasecmp() not working properly in my php script
<p>In the snippet of code below, I'm using the strcasecmp() function.  The function works fine for the first name match but does not for the last name.  </p>

<p>For example if I have the name Joe Black in for names file and submit blanks for the name, the value of $xxx and $yyy are -3 and -6 respectively.  If submit the name I get $xxx = 0 and $yyy = -1.  </p>

<p>Can someone tell what I am missing or doing wrong??</p>

<p>Thanks</p>

<p>Chris</p>

<pre><code>&lt;?php 
$fname = $_POST["fname"]; 
$lname = $_POST["lname"];

print "First Name: " .$fname; 
print "&lt; br/&gt;"; 
print "Last Name: " . $lname;

$namesFile = "namesFile.txt";

$numLines = count(file($namesFile)); 
print "&lt; br/&gt;"; 
print "Lines: " . $numLines;

$fh = fopen ($psswrdFile, "r");

for ($i=1; $i &lt;= $numLines; $i++) 
{ 
$lineData = fgets($fh); 
print "&lt; br/&gt;"; 
print $lineData;

list($firstName, $lastName) = explode(" ", $lineData);

print "First Name: " .$firstName;  

print "Last Name: " . $lastName;  

$xxx = strcasecmp($fname,$firstName);  

print "name " . $xxx;  

$yyy = strcasecmp($lname, $lastName);  

print "password" . $yyy;  
}

?&gt;
</code></pre>
