* Thus wrote Monty ([EMAIL PROTECTED]): > I tried removing the zeros, but, I get the same result: > > $id = 000011; > $id = ltrim($id, '0'); > echo $id; // Displays: 9 instead of 11 ??? > > This didn't work either: > > $id = 000011; > settype($id, 'string'); > $id = ltrim($id, '0'); > echo $id; // Displays: 9 instead of 11 ???
This is expected, $id becomes 9 as soon as you assign it. the ltrim() function's dont see any 0. this will work however: $id = "0000011"; echo (int)$id; - or $id = "0000011"; echo ltrim($id, '0'); > No matter what I do, $id=000011 is seen as "9". Only way is to pass the > number without the zeros ($id=11), but, because this data is being read from > a database, I can't change the format because PHP seems to be converting it > immediately to a 9 instead of reading it as 11 or even 000011. This shouldn't be happening. A variable that contains a value of '000011' will not be seen as on octal value. > > If PHP sees this as an octal, then why does gettype(000011) = INTEGER? This > makes no sense. Thats because 000011 is an integer in octal notation. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php