Display the drop-down list

sprintf()

« soundex | sqrt »
<?php
$string 
sprintf (
    
// string $format
    
// mixed $arg0
    
// mixed $arg1
    
  // mixed $arg2
);
?>
Result
$string = 'There are 5 monkeys in the tree'
Examples
#1 sprintf  ("There are %d monkeys in the %s",
 
5,
 
"tree")
#2 sprintf  ("The %s contains %d monkeys",
 
5,
 
"tree")
#3 sprintf  ('The %2$s contains %1$d monkeys',
 
5,
 
"tree")
#4 sprintf  ('The %2$s contains %1$d monkeys. That\'s a nice %2$s full of %1$d monkeys.',
 
5,
 
"tree")
#5 sprintf  ('The %2$s contains %1$04d monkeys',
 
5,
 
"tree")
#6 sprintf  ("%b",
 
43951789)
#7 sprintf  ("%c",
 
65)
#8 sprintf  ("%d",
 
43951789)
#9 sprintf  ("%e",
 
43951789)
#10 sprintf  ("%u",
 
43951789)
#11 sprintf  ("%u",
 -
43951789)
#12 sprintf  ("%f",
 
43951789)
#13 sprintf  ("%o",
 
43951789)
#14 sprintf  ("%s",
 
43951789)
#15 sprintf  ("%x",
 
43951789)
#16 sprintf  ("%X",
 
43951789)
#17 sprintf  ("%+d",
 
43951789)
#18 sprintf  ("%+d",
 -
43951789)
#19 sprintf  ("[%s]",
 
"monkey")
#20 sprintf  ("[%10s]",
 
"monkey")
#21 sprintf  ("[%-10s]",
 
"monkey")
#22 sprintf  ("[%010s]",
 
"monkey")
#23 sprintf  ("[%'#10s]",
 
"monkey")
#24 sprintf  ("[%10.10s]",
 
"many monkeys")
#25 sprintf  ("%04d-%02d-%02d",
 
"2014",
 
"2",
 
"15")
#26 sprintf  ("%01.2f",
 
123.1)
#27 sprintf  ("%.3e",
 
362525200)
See also
date, number_format, printf, sscanf, vsprintf