Like many other languages, PHP features the versatile printf()
and sprintf()
functions that you can use to format strings in many different ways. These functions are handy when you need convert data between different formats — either to make it easy for people to read, or for passing to another program.
PHP features many other functions to format strings in specific ways — for example, the date()
function is ideal for formatting date strings. However, printf()
and sprintf()
are great for general-purpose formatting.
In this tutorial you look at how to work with printf()
and sprintf()
to format strings.
[Read more…] about Formatting PHP Strings with printf and sprintf