Create routes with multiple parameters in Codeigniter

Asked

Viewed 260 times

0

I have a project developed in Codeigniter and I’m setting up some routes to get some nice Urls, but I found a problem.

In a given route, I don’t know how many parameters it will come with, you can come with 1 parameter or even 4 parameters. In the file routes.php, how I would set to recognize these parameters?

In this example it works, but I believe that it is not the correct one:

$route['vendas/(:any)'] = '$1';
$route['vendas/(:any)/(:any)'] = '$1/$2';
$route['vendas/(:any)/(:any)/(:any)'] = '$1/$2/$3';
$route['vendas/(:any)/(:any)/(:any)/(:any)'] = '$1/$2/$3/$4';
  • Friend, it would not be the case to fix a route and send the parameters by POST ?

  • In this specific case no, as for example, I am accessing a route vendas/detalhes, but I may have the route vendas/ativas/detalhes/id/5

  • I believe this link will help: https://www.codeigniter.com/userguide3/libraries/uri.html

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.