# Show a number to 2 decimal places?

What's the correct way to round a PHP string to 2 decimal places? $number = "520"; // It's a string from a DB$formatted_number = round_to_2dp($number); echo$formatted_number; The output should be 520.00; How should the round_to_2dp() function definition be?

## 1 Expert Answer

By:

Kwame O. answered • 06/05/19

Tutor
5 (8)

Experienced PHP Developer

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.