Jump to content

Archived

This topic is now archived and is closed to further replies.

briant

How do I turn 000123 to 123?

Recommended Posts

Thank you. I just figured out another way too:
$num = $num+0;                    // so it would turn into a number

but I guess your way is more correct, thanks again.

btw, intval don't really work because for some reason:
echo intval(042);                    // 34

Share this post


Link to post
Share on other sites
[code]<?php
$number = '000123';

echo number_format($number)."\n";
echo intval($number);
?>[/code] outputs [code]123
123[/code] for me...

Share this post


Link to post
Share on other sites
[code]
<?php
echo intval(042);                    // 34
echo '<br>';
echo intval('042');                  // 42

?>

042 means treat as an octal number (base 8)

'042' string value equal to 42[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.