I've got an ajax call that sends two arrays of data. Portals and Stubs. The headers look like this: portals[630][lat] -36.876755 portals[630][lng]: 174.767649 portals[630[photo]: http://lh3.googleusercontent.com/34nlTLv5ueIf4NksgJt5XzpEACGwWPCFqjyj0mgQLJYSJns03-LjzI6nr7fw64cgyfLfgU2OtDnPYG5a58Cxxj6zLa4 portals[630][name]: Eden Garden portals[631][lat]: -36.873148 portals[631][lng]: 174.761531 portals[631][photo]: http://lh3.googleusercontent.com/3EsLuaes-vXrvC-lfcA4-va4l8uoiC3uEys28q_7njbfMSpTKrbLsiSrvBSGAYB8lOtRGMGS_--R10GsNSlQ1PTrtw portals[631][name]: Gordon House - Wesley Dementia Care stubs[0][lat]: -36.865096 stubs[0][lng]: 174.77066 stubs[1][lat]: -36.872709 stubs[1][lng]: 174.766448 stubs[2][lat]: -36.864204 stubs[2][lng]: 174.770893 stubs[3][lat]: -36.875467 stubs[3][lng]: 174.73618 stubs[4][lat]: -36.861377 stubs[4][lng]: 174.769936 Code (markup): in my php script I have $portals = filter_input(INPUT_POST, 'portals', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); $stubs = filter_input(INPUT_POST, 'stubs', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); Code (php): $portals always has a list $stubs sometimes has a list, sometimes it's NULL. Even if I have no data, I'll always send an empty array so it should never be NULL When I output array_keys($_POST) only shows stubs sometimes which makes me think that it's not a filter_input problem. I can't see anything that would indicate why $stubs is failing. If I save the post variables to a file it's 192kb My hosting settings: post_max_size 8M (Default) So that shouldn't be a problem. Is there a gotcha with $_POST and arrays that I need to know about? Normally by the time I've tried to put down all the relevant info in a query I've found the thing I've tripped over. Not this time. I don't normally work with such large amounts of data but it's really not that much, surely. EDIT: I've found my culprit! in my PHP settings I have max_input_vars = 1000 which means it's been dropping off large portions of even the Portals array and explains a weird bug I hadn't worked my way through to. So being on shared hosting I can't just dive into php.ini I've added this to my .htaccess and will keep an eye on it. <IfModule mod_php7.c> php_value max_input_vars 5000 </IfModule> Code (markup):
Why don't you serialize and then base64 encode your 2 arrays and send as 1 single input var? Then on receiving end, you can decode unserialize and do your rest of processing. I read on stackoverflow that increasing input vars like this can leave the server vulnerable to service denial attacks.
That would work, instead I've just batched it up and made additional calls. Not as tidy but it does the trick.
Screw the dipshit parody of 1960's computing that is base64... Send it as one field as JSON. If this is JavaScript -- since @sarahk said AJAX -- USE IT!!! Data like this is precisely why formats like JSON and XML exist.