Results 1 to 2 of 2

Thread: Formatting a number

  1. #1

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Formatting a number

    Hi,

    I'd just like to know how number formatting goes in PHP.
    I need to format in the way: 1 = 0001, 23 = 0023 etc.
    I know there is a method involving printf, but that doesn't quite do the job.
    The thing is that I need it stored in a variable instead of printing it.

    Thanks,
    Delete it. They just clutter threads anyway.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Formatting a number

    $myvar = sprintf('%04d', $mynum);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width