I am trying to open a file and compare each line to a string to see if they are same or not, but it's not working, here is the code.
$toSearch="[email protected]";
$textData=array();
$fla=FALSE;
$file=fopen('text.txt','r') or die('Unable to open file.');
while(!feof($file))
{
  $textData[]=fgets($file);
}
fclose($file);
for($i=0;$i<count($textData);$i++)
{
  echo $textData[$i]."<br/>";
  if (strcmp($toSearch,$textData[$i])==0)
  {
      echo "Yes";
  }
}



\n) at the end of each$textData[$i], so it probably won't match? Why do you use strcmp anyway?strcmpis case sensitive. 2. use===comparison operatorshell_exec("grep -h '[email protected]' filename")if you get output then exist else no match foundwhile. What you are doing is overkill and you are wasting memory and cpu.shell_execisn't by default simpler ... especially if you aren't allowed to call it (some hosters are very picky)