Reputation: 3085
I have a number (as string) like this: 1.00000
How can I reformat such numbers to only look like 1?
Thanks
Upvotes: 9
Views: 42140
Reputation: 219894
Use number_format()
echo number_format('1.000000'); // prints 1
Or use intval()
echo intval('1.000000'); // prints 1
Or cast it as an integer
echo (int) '1.000000'; // prints 1
Upvotes: 35