The Following PHP if condition statement wrongly is not working. File $fname has text values: "990,1000" with a comma in between:
$myfile = fopen($fname, "r") or die("<script
type='text/javascript'>window.location.href =
'http://ift.tt/2ulkoA2';</script>");
$dt=fread($myfile,filesize($fname));
//File fname has values: "990, 1000"
fclose($myfile);
$myArray = explode(',', $dt);
//Now checking if Limit expired or not?
echo "<br>myArray[0] values is: " . $myArray[0] . " myArray[1] value is: " .
$myArray[1];
if ($myArray[0]>=$myArray[1]){
echo "<script>alert('You can't proceed further');</script>";
//echo "<script type='text/javascript'>window.location.href =
'register.html';</script>";
exit();
}
else{
echo "<script type='text/javascript'>window.location.href =
'gui.php';</script>";
echo "You can proceed";
exit();
}
When I run the above in a php file the if statement always takes value of myArray[0] >= myArray[1] as true and show the reigster.html whereas in the $fname file it is 990,1000 myArray[0]=990 and myArray[1]=1000 so myArray[0] should not be greater than myArray[1] and the else statement should run but the opposite is happening.
Any suggestions as to why this is not working? Many Thanks in advance for your answers.
Aucun commentaire:
Enregistrer un commentaire