$bal = (int)$balance;
echo is_int($bal);
$balance is from a file_get_contents($webservice);
I am using (int) to convert a string to integer. is_int returns 1 for true as verification.
Because the value of $bal is always negative, I do the following calculation to make it a positive:
$bal = $bal * -1;
When I do this, the value becomes 0 even though $bal may be -150 previously.
EDIT 1 var_dump ($balance) is returning: string(110) " -399.6000"
EDIT 2 I have used XML Parser to assign variable to array - see my answer below.
abs()instead of multiply be -1. Someday$balmay not always be negative.abs, there is nothing wrong with the provided code, and if$bal==-150&-1==-1, it will not give you 0. More likely, there is some garbage in$balance(currency signs, HTML tags, whitespace etc.) which prevents it from being cast to the desired INT. Normal handling would cast it to 0 if it cannot recognize a number.string(110) " -399.6000"does not compute, if you're looking in a browser, please look at the source, not the webpage, as-399.6000has far less then 110 characters.