PHP Function Printf - Format Strings and Values
A well-known feature in many languages is the ability to format strings and values to display them as desired. The php function printf is a powerful tool that allows you to do this in a variety of ways.
This article will walk you through the php function printf and show you how it can be used to format strings, numbers, dates, times and more in a very flexible way.
The function printf() takes two parameters; the first is a format string and the second are the values that will be inserted at each % sign in the format string. The function works "step-by-step" meaning that at the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted and so on.
If the format string contains any additional format specifiers, they will be inserted before the type specifier. These can be things like
This function also supports the ability to set the number of digits after the decimal point for floating numbers. This is done by adding a