Page 1 of 1

Retrieving values from a string

Posted: Wed Sep 05, 2007 3:51 am
by aceconcepts
Hi,

I have a string that contains values seperated by commas.

I don't know how many values will be in the string at any one time.

I want to be able to extract each value individually so that I can do something with them.

A text field will be used inside of a form to retrieve the input values. I am keen to use an array I'm just a little bit rusty with string manipulation.

How would one go about doing this?

Posted: Wed Sep 05, 2007 4:06 am
by CoderGoblin
From what I understand you have two choices... explode as you know you are separating by commas (If you can guarantee text does not have "textbock","text,block") or preg_match if it does (you'll have to work out the pattern to match your specific possibilities). In general I think explode will suffice. You then use the array created to do as you wish..

Posted: Wed Sep 05, 2007 4:39 am
by aceconcepts
Excellent. Thanks.