.
-Original Message-
From: Harry.de [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 10:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Zero Fill - Number Format
How can I put out a Zero Fill for numbers
The result should be
$something=26;
echo $something;
e.g.
026
--
PHP
wouldn't this just print empty spaces before the number instead of the
needed Zeros?
-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 1:11 AM
To: 'Harry.de'; [EMAIL PROTECTED]
Subject: RE: [PHP] Zero Fill - Number Format
sprintf/printf(%7d
PROTECTED]
Subject: RE: [PHP] Zero Fill - Number Format
sprintf/printf(%7d, $num)
-Original Message-
From: Harry.de [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 10:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Zero Fill - Number Format
How can I put out a Zero Fill
$something = 26;
$something = sprintf('%7d', $something);
$something = str_replace(' ', '0', $something);
echo $something;
This is a bit more direct:
$something = 26;
echo str_pad($something, 7, '0', STR_PAD_LEFT);
Chris
=
Become a better Web developer with the HTTP Developer's
oops, sorry - try this instead
sprintf/printf(%07d, $num)
-Original Message-
From: Boaz Yahav [mailto:[EMAIL PROTECTED]
Sent: Friday, March 21, 2003 8:23 AM
To: Martin Towell; Harry.de; [EMAIL PROTECTED]
Subject: RE: [PHP] Zero Fill - Number Format
wouldn't this just print empty spaces
How can I put out a Zero Fill for numbers
The result should be
$something=26;
echo $something;
e.g.
026
I didn't found a solution with number format. Is there any other way?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
sprintf/printf(%7d, $num)
-Original Message-
From: Harry.de [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 10:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Zero Fill - Number Format
How can I put out a Zero Fill for numbers
The result should be
$something=26;
echo $something
numbers appropriately.
-M
-Original Message-
From: Harry.de [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 6:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Zero Fill - Number Format
How can I put out a Zero Fill for numbers
The result should be
$something=26;
echo $something;
e.g
This one time, at band camp,
Harry.de [EMAIL PROTECTED] wrote:
How can I put out a Zero Fill for numbers
The result should be
$something=26;
print str_pad($something, 7, 0, STR_PAD_LEFT);
Kevin
__
(_ \
_) )
9 matches
Mail list logo