$value) { if (strpos($key, 'variable') === 0) { preg_match('/_(\d+)$/', $key, $matches); if (isset($matches[1])) { $index = $matches[1]; if (!isset($result[$index])) { $result[$index] = []; } $newKey = preg_replace('/^variable/', '', $key); $newKey = preg_replace('/_\d+$/', '', $newKey); $result[$index][$newKey] = $value; } } } $jsonResult = json_encode($result, JSON_PRETTY_PRINT); header('Content-Type: application/json'); echo $jsonResult; } ?>

Создание сущности

Вводимые переменные