« Comments on the blogs are fixed... | Main | Revenge of the Sith »

May 16, 2005

Stupid printf tricks

This came in handy today:

$padding = 30;
$header_len = ($padding - strlen($old_header));
$message = sprintf("%s%{$header_len}s", $old_header, $new_header);

And now I have consistent spacing between $old_header and $new_header. I love when I rediscover old functionality I had forgotten.

Posted by ed at May 16, 2005 4:34 PM

Trackback Pings

TrackBack URL for this entry:
http://weblogs.litmusgreen.com/mt-tb.cgi/658

Comments

Don't forget the somewhat more readable:

sprintf("%s%*s", $old_header, $header_len, $new_header);

Sorry. Slow day at work.

Posted by: MTS at May 17, 2005 1:34 PM

Post a comment




Type the characters you see in the picture above.


Remember Me?