believeinsharing Posted June 18, 2012 Share Posted June 18, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/264381-_posttxtbox1-to-array/ Share on other sites More sharing options...
trq Posted June 18, 2012 Share Posted June 18, 2012 Is there any way to store variable in array, They would be useless if you couldn't. Quote Link to comment https://forums.phpfreaks.com/topic/264381-_posttxtbox1-to-array/#findComment-1354838 Share on other sites More sharing options...
believeinsharing Posted June 18, 2012 Author Share Posted June 18, 2012 sorry I am new to PHP Quote Link to comment https://forums.phpfreaks.com/topic/264381-_posttxtbox1-to-array/#findComment-1354851 Share on other sites More sharing options...
cpd Posted June 18, 2012 Share Posted June 18, 2012 $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. Quote Link to comment https://forums.phpfreaks.com/topic/264381-_posttxtbox1-to-array/#findComment-1354852 Share on other sites More sharing options...
Mahngiel Posted June 18, 2012 Share Posted June 18, 2012 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(); Quote Link to comment https://forums.phpfreaks.com/topic/264381-_posttxtbox1-to-array/#findComment-1354855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.