Code Newbie
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 Newbie
    forums
Old 10-02-2002, 05:39 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
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 is offline   Reply With Quote
Old 10-03-2002, 05:46 AM   #2 (permalink)
toe_cutter
Code Monkey
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 79
toe_cutter is on a distinguished road
Send a message via ICQ to toe_cutter Send a message via AIM to toe_cutter Send a message via Yahoo to toe_cutter
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 is offline   Reply With Quote
Old 10-03-2002, 06:24 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
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 is offline   Reply With Quote
Old 10-03-2002, 11:10 AM   #4 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
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 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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:16 AM.


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