Tsallaka zuwa abun ciki
Justice Tech School

Formatting Numbers

number_format adds separators and decimals. printf formats with placeholders.

Example
echo number_format(1234567.891, 2), "\n";
echo number_format(1234.5, 2, ",", "."), "\n";
printf("%05.1f|%+d", 3.14159, 5);

Result

1,234,567.89
1.234,50
003.1|+5

Exercise

Thousands separator.

(1234.5, 2)

Quiz Test

What does number_format return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.