I want to send a array to php with this structure:
Array[0]['name'] = ...
Array[0]['def'] = ...
Array[1]['name'] = ...
Array[1]['def'] = ...
and so on....
To do this I have a multidimensional array object like this:
var allShapes = new Array();
$('.shape_name').each(function(index){
allShapes[index] = new Array();
allShapes[index]['name']=$(this).val();
allShapes[index]['def']=$(this).closest("tr").find('*[id*=shape_def_]').val();
});
I send it through a post request to php:
$.post("../some.php", {
'shape_defs' : allShapes
}, function() {
console.log(allShapes);
}, "json").success(function() {
console.log("success");
});
How do I have to iterate through thos array in php? Something goes wrong there......
The Array which comes as $_POST (after json_decode) has the following content:
[{"name":"Ta","def":"somestring"},{"name":"WSCall","def":"somestring"},{"name":"manual","def":"somestring"}]
How do I iterate to get the values of the keys?