Jump to content

[SOLVED] Make a textarea value into an array insert according to comma, line break, etc


msaz87

Recommended Posts

Hey all,

 

I was just curious if anyone had an example or could point me in the direction of something that would describe the process of making the values of a textarea into an array based on some sort of defined factor, such as a comma, a line break, etc.

 

In other words... if the contents of a text area were:

 

One, Two, Three, Four

 

Then each one of those words would insert separately into the DB

 

Any help is greatly appreciated. Thanks!

Link to comment
Share on other sites

I guess I need a little more help than I thought..

 

So if my textarea is:

 

<textarea name="divisions[]" cols="40" rows="5"></textarea>

 

And the code on the process page is:

 

$divisions 	= array_map( 'trim', explode( ',', $_POST['divisions[]'] ) );	

 

How would I echo that to make sure it's working properly and how would I then go about doing some sort of foreach to insert each separately into the DB?

 

Thanks again

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.