Forum Moderators: coopster

Message Too Old, No Replies

Breaking down a String in PHP 4

Creating an array with one character in each 'slot'.

         

inveni0

5:08 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



I need to split a string so that each character is in its own holder within an array. I know str_split will do it, but I need something compatible with PHP v4.

Any ideas?

inveni0

5:13 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



I think chuck_split will work, but any other ideas would be great, also.

inveni0

5:25 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



Actually, this will not work. What I have is a string like this:

12-15

The first two characters will always be numbers. I need to extract these two digits; however, the string may look like:

12 to 20

or

14(maybe 17)

Any ideas?

studawsons

5:32 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



I think substr may help you!

[uk.php.net...]

check out the manual :)

inveni0

5:39 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



substr is perfect! Thanks! That saves me a couple lines of code.

studawsons

5:56 pm on Dec 7, 2006 (gmt 0)

10+ Year Member



hehe! nice and easy way to go