Jump to content

$_POST['txtbox1'] to array


Recommended Posts

Is there any way to store variable in array,

 

I have set for loop in javascript to display textbox on form (textbox may be display from 1 to 5 depending on users requirement)

 

Now I want to add those textbox value to database.

 

is there any way to store that values in array so that I can use loop to run 'insert statement'

 

Thanks

Link to comment
Share on other sites

$myArray = array();
// OR
$myArray = []; // PHP 5.4+

$myArray[] = "foo";
$myArray['foo'] = "bar";

foreach($myArray as $key=>$val){
    // Do something
}

 

If you understand how arrays work in JS you should be able to use them in PHP.

Link to comment
Share on other sites

Is there any way to store variable in array,

$_POST is already an array.  try var_dump($_POST); and you'll see for yourself.

 

If you're wanting JS to do actions on your form before it's submitted, you can grab the value of it stupid simply with something like:

var textarea = $('#textarea').val();

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.