I am looking to breaking up a URL to key value pair in PHP for example
/name/foo/location/bar/account/3449
Result would be something like this
array(name => "foo", location => "bar", account => "3449");
Current solution:
$urlPieces = explode('/', $_GET['q']);
$results = array();
$count = 0;
$keyName = "";
foreach ($urlPieces as $key=>$value) {
if($count % 2 != 0){
$results[$keyName] = $urlPieces[$count++];
}else{
$keyName = $value;
$count++;
}
}