Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format a number to a String!! Pls Help! 1

Status
Not open for further replies.

Fori

Programmer
Joined
Jun 18, 2003
Messages
84
Location
MT
Hi All

i'm used to the vb function format($Number, "####0000").

Is there a way to do the same in php?

Thanks
Nicky
 
I'm no VB programmer... what're you trying to do?

Chances are DRJ's links will help you out... but if they don't odds are you'd be better served by telling us what you want instead of how you do it in another language.

-Rob
 
I have an order number: 1 but i want to display it as 0001!!

how can i do this?

Thanks
Nick
 
The task is fairly easy:
Code:
$newString = sprintf('%04d',$value);
Here's an explanation:
The forat for the conversion specification always starts with the percent sign (%). The '0' is the padding character. 4 is the minimum width and d means represent the input value as decimal number.
That's it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top