Alvian Casablancas
Alvian Casablancas

Reputation: 93

Writing URL variables in CodeIgniter?

I'm working on a project using CodeIgniter, though I still a bit new on this PHP language framework. I need to create multiple variables URL in CodeIgniter like:

index.php?page=10&filter=voted

How do you write it in CI? I know if it's only one variable then it should be

index.php/page/10

If the URL contains two or more variables, should it be like this or not? And how do you retrieve them since it uses URI Segment?

index.php/page/10/filter/voted

Much thanks for the help!

Upvotes: 1

Views: 72

Answers (1)

Aslam Patel
Aslam Patel

Reputation: 894

you can get data using segment.

 $this->uri->segment(1);
 $this->uri->segment(2);
 $this->uri->segment(3);

or get all segment in array

$segment = $this->uri->segment_array();
print_r($segment);

Upvotes: 1

Related Questions