Page 1 of 1

The unexplained!

Posted: Thu Dec 08, 2011 10:01 am
by spacebiscuit
Can anyone expalin this:

Code: Select all

echo $_SESSION[price];
$_SESSION[price]=$_SESSION[price]*2;
echo $_SESSION[price];
Output:

1,210.58
2

Why is session[price] losing its value?

Re: The unexplained!

Posted: Thu Dec 08, 2011 10:08 am
by Celauran
The comma ensures it's being treated as a string and giving it an intval() of 1. Strip the comma and everything works as expected.

Re: The unexplained!

Posted: Thu Dec 08, 2011 10:22 am
by spacebiscuit
Grrrr, thanks!