Hi,
This might have absolutely nothing to do with modx, but I’m getting to the point of tearing my hair out and I’m hoping someone here can help.
Currently I pass two tv’s as parameters on a snippet. When I call them immedietly upon reaching the snippet they print out fine. However once I try and convert the string to an integer, in order to do some basic maths on it, for some reason it converts the string to 0. I’ve tried several different methods, and I’m wondering if there is something that I am missing, as this conversion has worked fine on normal php files in the past.
echo "This is the type of initial netPrice:";
echo gettype($netPrice);
echo "<br/>";
echo $netPrice. " = NET PRICE<br/>";
echo intval($netPrice, 10);
$test = (int)$netPrice;
echo gettype($test);
echo "<br/>";
echo $test. " = Net Price as an int<br/>";
Which then prints out:
This is the type of initial netPrice:string
10.99 = NET PRICE
0
integer
0 = Net Price as an int
0 Test2
0 Test
I hope someone can spot a really simple mistake!
Thanks
Hollie