I am not sure if anyone can help me but I would really appreciate it.
I have a page that pulls information from the Globe Investor’s api. It is xml so I pull it in, parse it, and spit it back out with php.
A snippet of my code looks something like this (not including the xml parser).
<?php $last = $result['s:service']['s:content']['stock']['quote']['last']; $lastint = round($last, 3)+0; ?> <div class="LastPrice">Last Price <?php echo($lastint); ?></div>
The round part ads a zero before the decimal point so that it spits out: Last Price 0.29
rather than just .29
HOWEVER , here is my problem. I need there to be one more integer to the right of the decimal, even if it is zero.
there is a handy function to do just that! Its called number_format();
echo number_format($lastint, 3);
the 2nd parameter defines how many digits you want after the decimal point. There are two other optional arguments to define thousands and decimal separator character, so you could format the number like we do in my country 1 000,00 or like its done in the US 1 ,000.00
here is php manual page if you need further details: http://cz2.php.net/manual/en/function.number-format.php
Hope it heps, uDesignStudios
ohhhhh my gosh you are my favorite person in the entire world right now Thank you that was very helpful and everything is working how I want now
I’m glad I could help