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?
Retrieving values from a string
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
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..
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London