Welcome Guest, Not a member yet? Register   Sign In
I need some help I wanna pass this parameter to a Controller
#1

I wanna pass this parameter to a Controller in CI, for instance  {Controller}/{View}/{Params} , where {Params} I need it to be like code1+code2+code3 , is this possible ?  

for instance : Players/GetPlayersInfoByIdList/id1+id2+id3

or there is a better way to do it ?
Reply
#2

Can you not do it exactly as you have it and then explode it out when you get it into your controller?

Actually, a little more detail on what you are doing may be helpful.
R
Reply
#3

I've not had to do it, so I haven't checked it out, but from the documentation it seems that you can have any or at least some number of additional URL segments, which will be interpreted just like the third. That is...

Code:
http://www.example.com/controller/method/arg1/arg2/.../argn

Presumably then, your method would expect those arguments, with
Code:
function foo ($arg1, $arg2, $arg3='', $argn=false)
{
   // code
}

If it doesn't work that way, you should still be able to receive the set of arguments as a single argument, which as russ_kern pointed out, you can put into an array with the explode statement.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply
#4

Passing the variables as one string with seperators is a good idea, but there's another way:
PHP Code:
function test($name){
 
   $uri_seg $this->uri->uri_to_assoc();

 
   foreach($uri_seg as $para){
 
       // Do something with each of the URI segments passed in here after $name
 
   }

You can even define a default value for every parameter.
See CI's documentation: http://www.codeigniter.com/userguide3/li...i_to_assoc
Reply




Theme © iAndrew 2016 - Forum software by © MyBB