Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 12 revisions

By default code ignitors $_GET is unset. What do you do if you want to have the ease of query strings and uri segments at the same time, without having to optionary enable query strings? Tyy this simple help function.

Create a simple helper and call it request. Use ths function function getRequests() { //get a the default object $CI =& get_instance(); //deaclre an array of request and add add basic page info $reqestArray = array(); $requests =$CI->uri->segment_array(); foreach($requests as $request) { $pos = strrpos($request, ":"); if($pos >0) { list($key,$value)=explode(":", $request); if(!empty($value) || $value='') $reqestArray[$key]=$value; } } return $reqestArray ; }

Your url can be in the notation www.yoursite.com/index.php/class/function/request1:value1/request2:value2

To get the values from your request $request=getRequests(); echo $request['request1']; echo $request['request2'];

This function simply loops through the uri segements and picks up only elements with the nation request:value and returns the request array

Clone this wiki locally