how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled (/showthread.php?tid=51041) |
how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-18-2012 [eluser]faluci[/eluser] ** I've gooled for hours, and searched within stackoverflow. Found a few similar ones, but couldn't find a good answer yet.** I'm thinking of rewriting my project using codeigniter. I have a search.php with possible querystring: Code: search.php?o=1&kk=1&k=sales&kx;=&w=4&l=New+York,+NY,+USA&i=222&i=229&i=225&i=238&i=237&i=203&el=3&eu=10&ei=on&d=5&d=4&d=9&d=6&at;=&a=Any I found some mentioned about Code: $this->url->uri_to_assoc(); Code: /i/222/i/229/i/225/i/238/i/237/i/203 Code: /i/222/229/225/238/237/203 controllers/show.php Code: class show extends CI_Controller Code: http://localhost/index.php/show/get/l/0123/l/52/l/l2 the above code only returns the last input. Code: Array from url above, is there a way to retrive as an array as Code: Array or similar NOT using Querystring? ('cos if I enable Querystring I cant use other Codeigniter helping features etc) so I want my old project's querystring as an array something like Code: Array etc etc how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]M52 Studios[/eluser] Have you tried doing uri_to_string, and then perhaps using list() and explode() functions to get what you want into an array EDIT: I'm sorry, $this->uri->uri_string() how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]M52 Studios[/eluser] By the way, the reason why you are only getting this: Code: Array is because each time, the array key 'l' get rewritten, and that's the reason why you are only getting the very last parameter as the final array. Does that kind of make sense? how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]M52 Studios[/eluser] Enjoy! Code: class Welcome extends CI_Controller { Again, unless you know in advance what your 'keys' are going to be for each array, you'll have a hard time distinguishing what is the actual data vs its' identifier. So, the above function will work for every case, except for your last one, where the [dy] = New+York. how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]M52 Studios[/eluser] Here is URL and final array sample: URL: welcome/get_array/i/222/229/225/i/238/i/237/i/203/d/3234/i/65434/d/2344 Code: Initial Array from the URI string: how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]faluci[/eluser] My question is solved. Thanks M52 Studio. how to retrive complex $_GET variables as a multi-dimensional array? NOT using QUERYSTRING enabled - El Forum - 04-19-2012 [eluser]M52 Studios[/eluser] You're welcome! |