FastRoute icon indicating copy to clipboard operation
FastRoute copied to clipboard

Return variable as array

Open lookingdown opened this issue 3 years ago • 0 comments

Is there a way to get variables returned in an array instead of individually.. Like so Instead of $app->get('/nanna/{name}[/{id}[/{product}[/{size}]]]', function($name, $id, $product, $size ) {

Like so $app->get('/nanna/{name}[/{id}[/{product}[/{size}]]]', function(array $params ) {

And then access in $params ( $params['name'], $params[''id] etcetera) , that would be very useful no need to named variable in route setup et al and so on ..

Currently using Leocavalcante/siler Route and works like this.. but is not maintained anymore and need to use FastRoute (perhaps).. (also multiple optional middle segments AS well which I find useful)

:)

lookingdown avatar Feb 27 '22 17:02 lookingdown