Jump to content


Manipulating strings?

  • Please log in to reply
1 reply to this topic

#1 matfish

  • Members
  • PipPipPip
  • Advanced Member
  • 242 posts
  • LocationUK

Posted 20 October 2006 - 10:51 PM


Iv got a list such as:

Line 1
Line 2
Line 3

which I wanted to copy & paste into a text box then put them into an array as separate results. Also then display each line with a comma to output:

line 1, line 2, line 3,

Any ideas? Wanted to output the above and also put in array so I can do other stuff like put certain keywords into a database.


#2 akitchin

  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 20 October 2006 - 11:40 PM

look up explode() and implode() in the manual.  the former turns a string into an array based on whatever "splitting character" (called a delimiter) you want to stipulate, which in this case looks like it'd be a newline character "\n" (and/or carriage return, "\r").  implode() then does the opposite - glues together every value in an array with a certain character between each value, which in this case looks like it'd be ', '.

post back if you run into troubles or are confused about their use.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users