simplePHPRouter icon indicating copy to clipboard operation
simplePHPRouter copied to clipboard

Further options in url

Open AleksandarNeustadt opened this issue 3 years ago • 1 comments

` // www.webpage.com/component/blog/... Route::add("/component/(.*)", function($urlComponent){ echo $urlComponent; // resolt ist blog });

// www.webpage.com/component/blog/option/list
// this link will call first routh
    Route::add("/component/(.*)/option/(.*)", function($urlComponent, $urlOption){
         echo $urlComponent . " and " .$urlOption;
         // we hawe not this resolt see. we will see from first rout 
         // how to enable this secon ?
    });

`

AleksandarNeustadt avatar Sep 23 '22 21:09 AleksandarNeustadt

you should put the second before the first if you want it to work.... or not using (.) as regex but something like ([a-z-0-9]) instead. That will remove the '/' from the regex and keep only letters hyphens and numbers.

So something like this:

Route::add("/component/([a-z-0-9]*)", function($urlComponent){
echo $urlComponent;
});

Route::add("/component/([a-z-0-9]*)/option/([a-z-0-9]*)", function($urlComponent, $urlOption){
echo $urlComponent . " and " .$urlOption;
});

unikoca avatar Sep 24 '22 16:09 unikoca