Many support requests come from users who want to do some kind of text parsing. One of the most effective (and easiest!) ways of parsing scripts is by using the split() routinefunction.
Splitting a Multiline Text Custom Field
Let's say you want to get the value of the third line a multiline text field. At first, this may seem difficult but not if we use the split() routinefunction. For example:
|
...
Let's say you wanted to join all lines of our hypothetical multiline text field. You can either loop through all the elements and append each element together, or you can cheat and use the replace() routinefunction.
|
All this does is replace pipe separators found in an array with an empty string. The same thing can be accomplished by using the join() routinefunction:
|
...
As you can see, using the split() routine function can be used to parse text in surprising (yet effective) ways.
...