sprintf

string sprintf(string format, [mixed arg1]) 

Generates a formatted string.

Returns:

String; FALSE on error

Description:

sprintf() is used to generate formatted strings from one or more arguments. The format argument is a string consisting of normal text and/or special conversion specifications. Conversion specifications begin with a single percent symbol (%). A sample format string might look like this:

"There are %d days left to %s" 

The normal text in format is sent unmodified to the output of the function, while each conversion specification should be matched by an additional argument to sprintf(). Continuing the previous example, a complete call to sprintf() using the format string just described might look like this:

 $days = ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.