![]() |
Passing multiple parameters in a single URL Segment - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html) +--- Thread: Passing multiple parameters in a single URL Segment (/thread-47987.html) |
Passing multiple parameters in a single URL Segment - El Forum - 12-30-2011 [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/key1=val1;key2=val2;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/key1/val1/key2/val2/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! |