سؤال

I have been trying all morning but how would I this number 1304583496 to look like this

13.04583496

and the same goes for this number

456604223 to 4.56604223

There are always 8 numbers to the right.

هل كانت مفيدة؟

المحلول

Divide it with 100000000, or use "pow" function:

$number / pow(10, 8);

نصائح أخرى

You could also use the official number_format method after division to keep your ending zeroes and have your number displayed in a nice manner.

<?php
$num = 1304583496; //the number
echo number_format($num/100000000,8,"."," "); //number of decimals = 8, comma seperator is . and thousands seperator is a space here
?>

For more information on this function: http://www.w3schools.com/php/func_string_number_format.asp

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top