I use the strcmp() to compare two strings in php, code below:
$tagname = "td";
$acq_data = extracting_data_tagname($url, $tagname);
$dir = $acq_data[205];
echo "this is $dir";
echo strcmp($dir, "NW");
The Result print: this is NW -1
Why the strcmp($dir, "NW") =-1, it should be =0, Anyone can tell me what's the problem? Thanks!
If you think that $dir
has NW
value you should try with trim()
function:
echo strcmp(trim($dir), "NW");
If it will return 0, it means that you have some whitespaces at the beginning or at the end of $dir
variable.