Strings In Depth18 / 18
Up next

Format with sprintf

<?php
declare(strict_types=1);
$name = "Ada";
$score = 92.5;
// %s text, %.1f float, %05d zero-padded int
$line = sprintf("%s scored %.1f (id %05d)", $name, $score, 42);
echo $line, "\n";
What you're solving

format specifiers for text, floats, ints