- var_dump: documentation ( source)
- preg_match: documentation ( source)
- str_replace: documentation ( source)
<?php
$Address = "/clanek/12345/komentare";
$Map = array(
"/clanky" => "Clanky.php",
"/clanek/([^/]*)" => "Blog.php",
"/clanek/([^/]*)/komentare" => "Blog.php",
"/" => "Main.php"
);
foreach ($Map as $Key => $Value) {
if (preg_match('~^'.str_replace('~', '\~', $Key).'$~', $Address, $Matches)) {
echo "Obsauje: $Key\n";
var_dump($Matches);
}
}