Amit20 Posted September 24, 2011 Share Posted September 24, 2011 Hello Everyone! I have created a javascript array which now i want to pass to php, so php can store those values to mysql. So plz anyone can suggest me how do i pass it to php? Any help will highly be appreciated! Link to comment https://forums.phpfreaks.com/topic/247768-passing-javascript-array-to-php/ Share on other sites More sharing options...
xyph Posted September 24, 2011 Share Posted September 24, 2011 <?php echo '<pre>'; print_r( $_GET ); echo '</pre>'; // prevent infinite loop if( empty($_GET) ) { ?> <script type="text/javascript"> var array = new Array( 'value1', 'value2', 'value3', 'value4' ); var size = array.length; for( var i = 0; i < size; i++ ) array[i] = i + '=' + encodeURIComponent(array[i]); location.replace( 'http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; ?>?' + array.join( '&' ) ); </script> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/247768-passing-javascript-array-to-php/#findComment-1272323 Share on other sites More sharing options...
Amit20 Posted September 24, 2011 Author Share Posted September 24, 2011 Thank you Xyph for youe reply :D ;D Link to comment https://forums.phpfreaks.com/topic/247768-passing-javascript-array-to-php/#findComment-1272450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.