1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface { $data = $req->getParsedBody(); ksort($data); ksort($data['arr']); ksort($data['arr']['x']['y']); $resp->getBody()->write(json_encode($data)); return $resp; }