*********** EDIT **********
There was a problem with control flow, I nested one if inside the other with a few other modifications, and it works. Thanks
I am having trouble with string comparison using PHP. I have a working copy of string comparison to isolate the issue. It works fine until I get data from a web service(TradingView). I have used "==", strcmp(), and strcasecmp(). All with no success. I am grabbing data from a web service, so maybe its the wrong character set? I am not sure. Here is the code.
$entity = file_get_contents('php://input');
$txt = fopen("message.txt", "a");
fwrite($txt, $entity."\n");
$elements = explode(" ", $entity);
// 2. examine, elements[4] must be buy or sell to continue
$position = $elements[4];
if(strcasecmp($position, "buy") != 0){
fwrite($txt, "Not equal $position and buy\n");
exit(0);
}
if(strcasecmp($position, "sell") != 0 ){ //strcmp($var1, $var2) !== 0
fwrite($txt, "\"$position\" is not buy or sell, exiting\n");
exit();
}
I have used every string comparison I can find with zero luck. Please advise.