View Single Post
Old 02-05-2009, 07:50 PM   #5 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

In the most simplest code this could be shown as the following.

All the sprintf function is doing is taking your integer (14) and diving by 10 to give you a float (1.4). The rounding of the numbers, as seen in the sprintf, is necessary merely to limit the number of digits that are displayed subsequent to the decimal point. In the sprintf's example, we are limited to a mere one digit after the decimal point. In my example I don't use any rounding, although if need be we could use round. I have left this out though to keep the example simple.

Although, I do suggest using the sprintf method because it looks better and also you have more control in fewer lines, I hope the code below helps you understand the functionality behind Salathe's solution.

php Code:
$iNumber = 14;
$iTotal = 14 / 10;
echo $iTotal;
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote