Re: [PHP] String Help PLEASE!

2002-10-08 Thread Robert Cummings

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 -00- 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 -00-.
> 
> 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:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] String Help PLEASE!

2002-10-08 Thread Shane

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 -00- 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 -00-.

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?
Thanks a bunch folks!!!
- NorthBayShane

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php