Created
November 17, 2019 21:29
-
-
Save felixprojekt/09a3178b4ef7cfb95bd40b62c292e321 to your computer and use it in GitHub Desktop.
Create URL friendly string from Czech text in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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