php sprintf statement

The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser. The prototype follows:

sprintf - syntax

string sprintf ( string format [, mixed arguments] )

An example follows:

sprintf - example


$cost = sprintf ( "$%.2f", 43.2 );

Output :

$ 43.20




Content