News
Forums
Search
Members
Sign Up
My Code Newbie
Username
Password
Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET
C.N. Friends
Planet Rome
Link to Us!
Code Newbie
Code Forums
>
Application and Web Development
>
PHP
format numbers
User Name
Remember Me?
Password
Register
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
LinkBack
Thread Tools
Display Modes
10-02-2002, 05:39 PM
#
1
(
permalink
)
sde
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,446
format numbers
i need to make numbers a 2 digit number.
for example.. the number "7" needs to be "07".
i can't get num_format() to do anything correct for me.. any ideas?
sde
View Public Profile
Visit sde's homepage!
Find More Posts by sde
10-03-2002, 05:46 AM
#
2
(
permalink
)
toe_cutter
Code Monkey
Join Date: Aug 2002
Location: Boston, MA
Posts: 79
Why?
If it is for just visualization then you can just echo "0"; before any number < 10.
Or is it for another reason?
Toe
__________________
toe_cutter
View Public Profile
Visit toe_cutter's homepage!
Find More Posts by toe_cutter
10-03-2002, 06:24 AM
#
3
(
permalink
)
sde
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,446
good point.. i was trying to keep it neat.. but now that i think about it, i may as well just make the database field "varchar" and enter it how it should be displayed.
but great idea , thanks =)
sde
View Public Profile
Visit sde's homepage!
Find More Posts by sde
10-03-2002, 11:10 AM
#
4
(
permalink
)
sdeming
Code Monkey
Join Date: Jul 2002
Location: Michigan
Posts: 85
You can use the printf() function just like in C:
PHP Code:
{
printf
(
"%02.2d"
,
$number
);
}
Should do exactly what you need.
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming
View Public Profile
Visit sdeming's homepage!
Find More Posts by sdeming
Bookmarks
Digg
del.icio.us
StumbleUpon
Google
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Display Modes
Linear Mode
Switch to Hybrid Mode
Switch to Threaded Mode
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
BB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Trackbacks
are
On
Pingbacks
are
On
Refbacks
are
On
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Adding Variable Numbers
falsepride
HTML, XML, Javascript, AJAX
1
10-28-2004
01:23 PM
adding numbers doesn't add up !!! help
arwilliams
HTML, XML, Javascript, AJAX
3
09-30-2004
10:17 AM
using sprintf to format a number
Epsilon
PHP
1
08-24-2004
07:30 PM
Trying to get mm/dd/yy format
ten_d
Standard C, C++
4
03-22-2004
07:54 PM
windows timestamp format?
sde
Windows
4
07-18-2003
12:09 PM
All times are GMT -8. The time now is
05:30 AM
.
Contact Us
-
CodeNewbie.com
-
Archive
-
Top
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by
vBSEO
3.0.0 RC8
Copyright © 2000-2008,
Milano Interactive
Web Hosting provided by
Portal 360 Web Hosting
LinkBack
LinkBack URL
About LinkBacks