$_GET['id']))[0]; if (isset($_POST['create'])) { $inputs = $_POST; $filteredInputs = []; foreach ($inputs as $key => $value) { if (strpos($key, 'modelinput_') === 0) { $filteredInputs[$key] = $value; } } ksort($filteredInputs); $result = []; $counter = 1; foreach ($filteredInputs as $key => $value) { $result[$counter] = [ 'value' => $value ]; $counter++; } $jsonResult = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); DB::query('INSERT INTO entities_data VALUES (\'0\', :title, :createdate, :entityid, :comment, :content)', array(':title' => $_POST['title'], ':createdate'=>time(), ':entityid' => $_POST['entityid'], ':content' => $jsonResult, ':comment' => $_POST['comment'])); header('Location: /admin?type=Models'); } ?>