Skip to content

Instantly share code, notes, and snippets.

@phosphore
Created June 30, 2016 10:27
Show Gist options
  • Save phosphore/65f53bebc417b930131b4987ba18af61 to your computer and use it in GitHub Desktop.
Save phosphore/65f53bebc417b930131b4987ba18af61 to your computer and use it in GitHub Desktop.
preg_match("/^\/per-(.*?)(-a-(.*))?\.html/", $this->uri, $matches); // vediamo se l'uri è /per-qualcosa.html o /per-qualcosa-a-luogo.html
if (count($matches) === 0) { // è solo una città
preg_match("/^\/(.+)\.html/", $this->uri, $cityArray);
$city = $cityArray[1];
echo $city;
} else if (count($matches) === 2) { // solo una professione $matches[1]
$profession = $matches[1];
echo $profession;
} else { //una professione e una città
$profession = $matches[1];
$city = $matches[3];
echo $profession. " " .$city;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment