/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $x = "/blog/index/1?foo=2&bar=4"; //$x = "/blog/index/1"; $url_part = $url_data[0]; $query_part = ""; $query_part = $url_data[1]; } // parse url part $controller = ""; $action = ""; $id = ""; $controller = $temp_url_parts[0]; $action = $temp_url_parts[1]; } $id = $temp_url_parts[2]; } } // parse query params $query_part = $url_data[1]; foreach($temp_query_parts as $q){ $key = $temp[0]; $value = $temp[1]; $query_parms[$key] = $value; } } "controller" => $controller, "action" => $action, "id" => $id, "get" => $query_parms, "post" => $_POST ); ?>