Page 1 of 1

substr help

Posted: Fri May 05, 2006 7:15 am
by slash85
hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi quick question:

When doing the following substr then incrementing by one:

Code: Select all

$GetMemberURN = "URN000001";

$URN = substr($GetMemberURN, 0, 3);

$Number =  substr($GetMemberURN, 0, 6) +1;  

$MemberURN = $URN . $Number;

echo $MemberURN;
returns URN2 how can i get it to keep the zero's eg: URN000002


Thanks in advance,
Slash.


hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri May 05, 2006 8:30 am
by slash85
hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color][/b]


Sorry made a mistake:

Revised:

php:

Code: Select all

$GetMemberURN = "URN000001"; 

$URN = substr($GetMemberURN, 0, 3); 

$Number =  substr($GetMemberURN, 3, 6) +1;  

$MemberURN = $URN . $Number; 

echo $MemberURN;

hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color][/b]

Posted: Fri May 05, 2006 10:56 am
by feyd

Posted: Mon May 08, 2006 6:58 am
by slash85
Thanks for the help i went with str_pad(). Worked a treat!