Skip to content

Instantly share code, notes, and snippets.

@felixprojekt
Created November 17, 2019 21:29
Show Gist options
  • Save felixprojekt/09a3178b4ef7cfb95bd40b62c292e321 to your computer and use it in GitHub Desktop.
Save felixprojekt/09a3178b4ef7cfb95bd40b62c292e321 to your computer and use it in GitHub Desktop.
Create URL friendly string from Czech text in PHP
<?php
public function createUrl($string)
{
$output = preg_replace('~[^\\pL0-9_]+~u', '-', $string);
$output = trim($output, '-');
$output = iconv('UTF-8', 'us-ascii//TRANSLIT', $output);
$output = strtolower($output);
$output = preg_replace('~[^-a-z0-9_]+~', '', $output);
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment