flatten missed

This commit is contained in:
CHIEFSOFT\ameye
2025-06-13 23:11:58 -04:00
parent bf5fdb4257
commit f2035c2b43
+12 -1
View File
@@ -58,7 +58,7 @@ class BackOffice extends BaseController
// }
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$in = flatten(json_decode(file_get_contents('php://input'), true));
$in = $this->flatten(json_decode(file_get_contents('php://input'), true));
}
if ($_SERVER["REQUEST_METHOD"] == "PUT") {
parse_str(file_get_contents('php://input'), $in);
@@ -82,4 +82,15 @@ class BackOffice extends BaseController
return $this->respond($this->summaryReturnData($in,$out,[]), 200);
}
private function flatten($data, $parentkey = "") {
$result = array();
foreach ($data as $key => $val) {
if (is_array($val)) {
$result = array_merge($result, flatten($val, $parentkey . $key . "_"));
} else {
$result[$parentkey . $key] = $val;
}
}
return $result;
}
}