Welcome Guest, Not a member yet? Register   Sign In
filter arguments
#1

hi, let's say i have this route: /user/(:num)
how can i pass the value insude (:num) to a filter?
i've read the documentation but it only show an example with hard-coded values.
Reply
#2

$uri->getSegments() will give you an array of all segments:
PHP Code:
$uri = &$request->uri;
$segments array_filter($uri->getSegments()); 

For /user/(:num), $segments[0] will be ‘user’ and $segments[1] will be the user id.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(06-28-2021, 01:53 PM)includebeer Wrote: $uri->getSegments() will give you an array of all segments:
PHP Code:
$uri = &$request->uri;
$segments array_filter($uri->getSegments()); 

For /user/(:num), $segments[0] will be ‘user’ and $segments[1] will be the user id.

super helpful, thanks a lot
Reply




Theme © iAndrew 2016 - Forum software by © MyBB