Jump to content

Manipulating strings?


matfish

Recommended Posts

Hi,

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.

TIA
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.