I have the following line in my code which displays my output in 6 characters with leading zeros.
$formatted_value = sprintf("%06d", $phpPartHrsMls);
I want to replace the leading zeros with spaces. Have tried all the examples found by searching this site and others and cannot figure it out.
Here are some I have tried:
$formatted_value = sprintf("%6s", $phpPartHrsMls);
$formatted_value = printf("[%6s]\n", $phpPartHrsMls); // right-justification with spaces
In the browser, spaces will always be collapsed.
Try:
<pre><?php echo $formatted_value; ?></pre>
And once you're satisfied with that, take a look at the CSS white-space:pre-wrap
- a very useful property!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With