Re: String Help PLEASE!
| From: | Robert Cummings | Date: | Tue, 08 Oct 2002 18:21:59 +0000 |
| Subject: | Re: String Help PLEASE! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119312@lists.php.net to get a copy of this message | ||
Shane wrote:
>
> Greetings gang, this should be an easy one but it's kicking my butt today.
>
> I need to build a member number in the format of 0000-00-0000 from an auto increment ID field
> from my DB.
>
> I can get the last ID value easy enough, but how the heck can I tag the new ID on to the end of
> the string 0000-00-0000.
>
> I looked in the manual at chr(), Parse_str() and str_replace() thinking that would do it, but
> no luck.
>
> Can someone point me in the right direction please?
Easy peasy...
$foo = sprintf( '%010ld', 1001223003 );
echo $foo."\n";
$fee =
substr( $foo, 0, 4 ).'-'
.substr( $foo, 4, 2 ).'-'
.substr( $foo, 6, 4 );
echo $fee."\n";
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'