• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1411
  • Last Modified:

number format to percentage

What number format do I use for php if I want to convert results to a percentage.

i.e. I have a result that is 0.1375 and I want it to be rounded to one decimal place so it shows 13.8%

How can I do this?
1 Solution
Try this


function perc($num) {
return number_format($num * 100,1)." %";

echo perc(0.1375);
petewinterAuthor Commented:
Many Thanks

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now