Passing multiple parameters in a single URL Segment |
[eluser]CroNiX[/eluser]
On occasion, I've wanted to pass multiple parameters in a single url segment, much like a query string. This is similar to $uri->uri_to_assoc() except it uses a single segment. For instance, take the following URL structure: http://yoursite.com/controller/method/ke...;key3=val3 Code: $values = $this->uri->segment_to_assoc(3); //or $this->uri->rsegment_to_assoc(3); for routed segments I just believe this is more semantic (in certain scenarios) than: http://yoursite.com/controller/method/ke.../key3/val3 Code: $values = $this->uri->uri_to_assoc(3); Read the notes. You have to add 2 characters to your $config['permitted_uri_chars'] (;=). I created this for a pagination library I'm using so I could: www.yoursite.com/controller/method/page=1;perpage=25;filter1=url;filter2=company_name;order=desc Code: $pagination_config = $this->uri->segment_to_assoc(3); Anyway, here it is on Github if it would be of use to you. If you find anything that needs fixing, please let me know or initiate a pull request! |
Welcome Guest, Not a member yet? Register Sign In |