|
-
Jan 23rd, 2008, 01:55 AM
#1
Thread Starter
Frenzied Member
modify number to string (ex: 1234 = 000-001-234)
Still a LOT I need to learn about PHP obviously.
I got a number (which is the id of a new record).
Now I want to build custom reference number (co_code-type_code-country-code-nnn-nnn-nnn)
So say i have anumber 1234 my reference number will look like SP-AG-CH-000-001-234)
So my question is how to make 1234, a string that will be 000-001-234?
-
Jan 23rd, 2008, 02:01 AM
#2
Thread Starter
Frenzied Member
Re: modify number to string (ex: 1234 = 000-001-234)
so far so good...now just for that hyphens
Code:
$refnum = "SP-AG-".$country_code."-";
$num = rand(100, 100000000);
$num = str_pad($num, 9, "0", STR_PAD_LEFT);
//HOW TO ADD HYPHENS BETWEEN EACH 3RD NUM?
$refnum= $refnum.$num;
return $refnum;
hmmm....thousands seperator? lemme check that.....
-
Jan 23rd, 2008, 02:07 AM
#3
Thread Starter
Frenzied Member
Re: modify number to string (ex: 1234 = 000-001-234)
nevermind..no need to use id from database
so just get 3 random numbers 3 times, pad them to the let with zero's, and the concacenate the lot together...
thanks for reading and wasing your time!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|