//matches[0] holds some preg_match'ed values
for($i=0;$i<count($matches[0]);$i++)
{
$price = $matches[0][$i]; //a**uto type casting to (float) returns 0 for $price. Tried it for values greater than 1 too.**
//echo gettype($price);
$price = $price + 0.01; **//Returns 0 + 0.01 instead of the right answer**
//**even after removing the above statement it does not compare**
if($price <= 1.50 && $price >= 1.00){ //because it should auto type cast to float, which it does no...
echo "here";
$price = $price+0.50;}
//strcmp always returns a '1' where 1 is surely not expected (not equal)
else if(strcmp($price,"1.50") > 0) && strcmp($price,"2.00") < 0 ){
echo "here 2";
$price = $price+0.50;}
}
Does this not work because $price is a constant as it belongs to a loop ?
I tried the same thing normally, without the loop, and it typecasts properly.
Am I missing something here ?