php-general | 2004032
Date: 03/30/04
- Next message: William Lovaton: "Re: [PHP] Re: TUX web server replacement"
- Previous message: Bruno Santos: "[PHP] imagecreatefromjpeg"
- Next in thread: Jason Barnett: "[PHP] Re: Having trouble formatting width using printf() and default spaces"
- Reply: Jason Barnett: "[PHP] Re: Having trouble formatting width using printf() and default spaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm using a for() loop to generate random die rolls. I'd like the
numbers to be formatted in a grid.
for ($i = 0; $i < 100; $i++) {
if (!($i % 5)) {
print("<br />");
}
printf("%'.10u", rand(1,$sides));
}
Currently, I'm padding with '.', but I'd like to pad with the default
spaces.
For example, printf("%10u", rand(1,$sides)); Except the numbers end up like,
7 10 14 19 3
4 6 16 13 2
etc.
Why is it that when I leave out the padding character, the output isn't
padded?
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: William Lovaton: "Re: [PHP] Re: TUX web server replacement"
- Previous message: Bruno Santos: "[PHP] imagecreatefromjpeg"
- Next in thread: Jason Barnett: "[PHP] Re: Having trouble formatting width using printf() and default spaces"
- Reply: Jason Barnett: "[PHP] Re: Having trouble formatting width using printf() and default spaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

