What function in PHP can be used to output a For loop counter as a two-digit number?
To output a For loop counter as a two-digit number in PHP, you can use the str_pad() function. This function pads a string to a certain length with another string (in this case, '0') on the left side. By using str_pad() with a width of 2 and a padding character of '0', you can ensure that the loop counter is always displayed as a two-digit number.
for ($i = 1; $i <= 10; $i++) {
$counter = str_pad($i, 2, '0', STR_PAD_LEFT);
echo $counter . "\n";
}