Pass javascript array to php by using curly braces key name
- by user7031
My js code:
$(function(){
var arr = new Array('jj', 'kk', 'oo');
$.post('test12.php', {'arr[]': arr}, function(data){
alert(data);
});
});
PHP code:
<?php
echo print_r($_POST['arr']);
The thing is,$.post receive a key named 'arr[]',it should be used in PHP as 'arr[]' instead of 'arr',but '$_POST['arr[]']' doesn't…