Menus & Navigation
|
|
|
|
<?php // extract variables from directory style GETs $res = explode("index.php/", $REQUEST_URI);
If (count($res) > 1) {
// THANK YOU YARAGN@YARAGN.CO.UK FOR THIS WONDERFUL CODE. CAN I BE YOUR FRIEND.
$rest = explode("?",$res[1]);
$vars = explode("/", $rest[0]);
FOR ($i=0; $i < count($vars); $i++) {
If (substr($vars[$i],strlen($vars[$i])-2,2)
== "[]") {
$temp = substr($vars[$i],0,strlen($vars [$i])-2);
${$temp}[] = $vars[$i+1];
} Else {
If (isset($vars[$i+1])) ${$vars[$i]} = $vars[$i+1];
}
$i++;
}
} ?>
|
|
|
Usage Example
|
put it at the top of your file, call the file with /something.php/something/else/somearray[]/val1/somearray[]/val2
and voila, you get $something = "else";
and a $somearray containing ("val1","val2");
so there.
|
|
|
Rate This Script
|
|
|
|