Welcome Guest, Not a member yet? Register   Sign In
How to pass array in URL?
#1

[eluser]NikhilSukul[/eluser]
Hi,

I have a url which will be containing:

controllername/functionname/param1/param2/param3/param4.. till param 7.

I don't want to have a functionname with (param1,paramm2,.....param7), instead is it possible that i can have a functionname calling with paramArray, or no params, as then i will be able to get it from the url or then i can use $this->uri->segment_array() or something like that to get all the params?

Please do reply me, i need this functionality urgently.
#2

[eluser]rogierb[/eluser]
Typing your message took more time then using to search function would have

Just a tip...
#3

[eluser]tobben[/eluser]
You mean something like this?

Code:
<?php

class Pages extends Controller {

    function __construct()
    {
        parent::Controller();
    }
    
    function index()
    {
        
    }
    
    function lol()
    {
        die(print_r($this->uri->segments));
    }

}

/* End of file pages.php */
/* Location: ./system/application/controllers/pages.php */


$this->uri->segments would return:

Code:
Array
(
    [1] => pages
    [2] => lol
    [3] => i
    [4] => got
    [5] => one
    [6] => milllion
    [7] => vars
    [8] => over
    [9] => here
    [10] => omg
)

On a URL like http://dev/pages/lol/i/got/one/milllion/...r/here/omg

to build it.. follow the link posted above
#4

[eluser]NikhilSukul[/eluser]
Thanks, now it works for me like this

i just need to create a function with a default param like

Controller is blog
function comments(array="")
{
array=$this->uri->segment_array();
}

so the url can be http://baseurl/blog/comments/abc/xyz/test/dfdf/dfdfdff

it will give me all the elements as array.

thanks




Theme © iAndrew 2016 - Forum software by © MyBB