How can printf be used to fill spaces as padding in PHP?

When using printf in PHP, you can specify a width for the output, which will add padding spaces to align the text. To fill spaces as padding, you can use the %s format specifier along with a width parameter. This will ensure that the output is padded with spaces to reach the specified width.

$name = "John";
$age = 30;

printf("Name: %10s, Age: %5d", $name, $age);