note 69966 added to function.sprintf
| From: | FredrikRambrisinthecomtopdomain at osu1 dot php dot net | Date: | Thu, 28 Sep 2006 09:48:58 +0000 |
| Subject: | note 69966 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117765@lists.php.net to get a copy of this message | ||
The C implementation of printf (alteast in glibc) can handle field length as arguments like this:
printf("[%-*s]\n", (int)20, "Hello");
To have the same result in PHP you need to run
printf("[%s]\n, str_pad("Hello", 20) );
It would be nice if one could use the field length directly like in C.
----
Server IP: 129.16.214.50
Probable Submitter: 212.247.90.194
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit -- https://master.php.net/note/edit/69966
Del: integrated -- https://master.php.net/note/delete/69966/integrated
Del: useless -- https://master.php.net/note/delete/69966/useless
Del: bad code -- https://master.php.net/note/delete/69966/bad+code
Del: spam -- https://master.php.net/note/delete/69966/spam
Del: non-english -- https://master.php.net/note/delete/69966/non-english
Del: in docs -- https://master.php.net/note/delete/69966/in+docs
Del: other reasons-- https://master.php.net/note/delete/69966
Reject -- https://master.php.net/note/reject/69966
Search -- https://master.php.net/manage/user-notes.php