Jump to content

Recommended Posts

Ok, here we go again!  I have been trying to solve this for a while:

 

I have a DB with a column full of numbers.  Some of these numbers are very big and, when they are stored in the DB they are stored in the scientific notation format, such as 1000000=1e+06.  I would like to take these numbers from a DB, and show them as integers.  Right now if I do this:

 

echo $numberfromdb;  my output is '1e+06'

 

If I try the following:

 

$numberfromdb = 1e+06;

$formattednumber = (int) $numberfromdb;

echo $formattednumber; my output is '1'

 

My quick solution was to change the DB column from 'float' type to 'bigint' type.  However, I just realized that I have made a big boo-boo.  I have several numbers which are fractions in decimal form (such as .50 and .25) and they have all been replaced with the number 1.  Should be fun going back through 2300+ entries to fix this.  Anyways, I am back to square one.

 

How do I get 1e+06 to echo as 1000000???  Please help!  This is very important and semi urgent.

genericnumber1,

 

Thanks so much.  I can't believe I would get a working solution so fast!  I have posted about this previously, and gotten many replies, but I could not get any of them to work.  Thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.