Created
January 23, 2012 17:08
-
-
Save westonwatson/1664285 to your computer and use it in GitHub Desktop.
URI Parsing in CodeIgniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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