Splitting a String
Posted: Tue Jul 05, 2005 2:52 pm
Something I have been trying to get for a while is this:
the number " 80001-99-005 " translates to 800010990005 when encoded by our barcoding script (because "-" is not allowed by I25 barcoding format). So I need to write a php function that will split the number into 3 segments. The first segment needs to be the first 5 characters, 80001. The second segment needs to be the next 3 characters 099. And if there is three more characters, I need that to be the last segment.
I guess what I am asking is whether or not there is a PHP function that can do what I need. Any help will be appreciated.
[edit] I would really like for each split segment to be contained in its own variable, like $seg1, $seg2, $seg3. Or an array would work fine [/edit]
Jud
the number " 80001-99-005 " translates to 800010990005 when encoded by our barcoding script (because "-" is not allowed by I25 barcoding format). So I need to write a php function that will split the number into 3 segments. The first segment needs to be the first 5 characters, 80001. The second segment needs to be the next 3 characters 099. And if there is three more characters, I need that to be the last segment.
I guess what I am asking is whether or not there is a PHP function that can do what I need. Any help will be appreciated.
[edit] I would really like for each split segment to be contained in its own variable, like $seg1, $seg2, $seg3. Or an array would work fine [/edit]
Jud