function flattenArray($array, &$resultArray = [], $name = '')
{
foreach($array as $key => $value) {
if (is_array($value)) {
flattenArray($value, $resultArray, $name ? $name."[$key]" : $key);
} else {
$resultArray[$name ? $name."[$key]" : $key] = $value;
}
}
return $resultArray;
}
fetch(url, {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(result => { ... });