Forum Moderators: coopster

Message Too Old, No Replies

Splitting apart a string

How to explode with no seperator

         

russkern

1:45 pm on Mar 2, 2008 (gmt 0)

10+ Year Member



Hi All,

I have a string of numbers (could include characters as well)

EX: 1230123456987

I want to seperate the First 3 characters as one element and the last 3 as an element so I can use them as variables.

I assume this is similar to an explode() function, but as I have no seperator (and would prefer to avoid one) I'm not sure where to begin.

Is it basicly a "First 3 as $var1" & "last 3 as $var2" ?

Thanks in advance

jatar_k

1:58 pm on Mar 2, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try substr [php.net]

russkern

4:45 pm on Mar 2, 2008 (gmt 0)

10+ Year Member



Looks as though that will do the trick...

Thank you much.

R