1

I have a problemi in using an IF statement with a string read from a file through fgetcsv command. The file start with Country (without quotes) in the first position so I put an IF statement at the beginning of my code in order to verify that the file is correct. The IF statement is:

if ($data[0]=="Country") {
…
} else { 
print $data[0] 
}

The IF statement fails but... on the screen I see the word Country. It means that the fgetcsv works well, but there are problems on string comparison. Can anyone tell me why the IF statement fails?

Thanks in advance for any help

giorgio

1 Answers1

0

Try comparing like this:

if (strtolower(trim($data[0])) == 'country') {
  echo 'found';
} else { 
  print $data[0] 
}