I'm sure there's a simple way to do this, I'm guessing by using intval.
I need to take the value of a variable, e.g. '42', and turn it into a length of 5 characters before outputting to csv. e.g. '00042'
Using intval to return numeric value at a certain length?
Moderator: General Moderators
-
KeeganWolf
- Forum Newbie
- Posts: 19
- Joined: Thu May 14, 2009 3:13 pm
Re: Using intval to return numeric value at a certain length?
if you're looking to simply add zeros, check out str_pad()
Re: Using intval to return numeric value at a certain length?
Or for a more numeric approach, sprintf.
Code: Select all
echo sprintf("%05u", 42);-
KeeganWolf
- Forum Newbie
- Posts: 19
- Joined: Thu May 14, 2009 3:13 pm