I'll give this a crack.
Just before we start, This would be a good question for you to read over.
You can't send an empty array because it'd look something like this: file.php?arra[]
.
You'll need to do this when sending:
$.post('dealWithStuff.php',{'fullArray':['hello','goodby'],'emptyArray':['']});
Notice how emptyArray
is ['']
instead of []
?
This will give you a response that looks like this:
Array
(
[fullArray] => Array
(
[0] => hello
[1] => goodby
)
[emptyArray] => Array
(
[0] =>
)
)
You'll be able to access it from the backend, you'll just have to remove that child array element from within the emptyArray
.
easily done with something like this:
foreach($_POST['emptyArray'] as $i => $derp) {
unset($_POST['emptyArray'][$i]);
}
Presuming you don't want any items in the emptyArray
.
After that, you'll get a return that looks like this:
Array
(
[fullArray] => Array
(
[0] => hello
[1] => goodby
)
[emptyArray] => Array
(
)
)