Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created January 23, 2012 17:08
Show Gist options
  • Save westonwatson/1664285 to your computer and use it in GitHub Desktop.
Save westonwatson/1664285 to your computer and use it in GitHub Desktop.
URI Parsing in CodeIgniter
//Codeigniter, a clever way to get data out of the Request URI.
private function getRequests(){
//get the default object
$CI =& get_instance();
//declare an array of request and add add basic page info
$requestArray = 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='') $requestArray[urldecode($key)]=urldecode($value);
}
}
return $requestArray ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment