bigint value from mysql database showing unwanted 0's

So i have a bigint stored in a table. Say the value of the element is 100. The property of the attribute is bigint size 20.

Now there is a chance that my app would generate a big int of size 20 digits. Now say for the dummy value 100, php echo's "00000000000000000100" instead of "100".

How do I get it to echo only "100" ?
LVL 12
lexxwernAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GarbsTheTurtleCommented:
To simply remove the leading 0's and return only 100:

$num = '00000000000000000100';
$num = ltrim($num,'0');

this will reset the value of $num to be simply 100 - we're telling ltrim() (left trim) to drop all leading '0' characters, and only the '0' charachters, from the beginning of the string.
RoonaanCommented:
change the database column to bigint size 1.

The size property has nothing to do with the largerst integer that can be stored. It is used for zerofilling (like you noticed :-) ).
When you have size=16, the returned number will be zero-filled until it has length 16.

When you are unable to change the database, you can use:
$num = 1 * $num;

-r-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lexxwernAuthor Commented:
And I thought PHP was the fool, turned out me is the idiot.

=)

Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.