An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
July 23, 2021 07:40 pm GMT
Original Link: https://dev.to/aradpardaz/php-create-slugify-url-from-all-language-to-english-229g
PHP Create slugify URL from All language to English
PHP transliterator_transliterate - examples . These are the top rated real world PHP examples of transliterator_transliterate extracted from open source projects. You can rate examples to help us improve the quality of examples.
Programming Language: PHP
Method/Function: transliterator_transliterate
(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)
...
Description
public Transliterator::transliterate ( string $subject [, int $start [, int $end ]] ) : string|false
Parameters
transliterator
In the procedural version, either a Transliterator or a string from which a Transliterator can be built.
subject
The string to be transformed.
start
The start index (in UTF-16 code units) from which the string will start to be transformed, inclusive. Indexing starts at 0. The text before will be left as is.
end
The end index (in UTF-16 code units) until which the string will be transformed, exclusive. Indexing starts at 0. The text after will be left as is.
Code Example 1:
<?phpfunction slugify($string){ $string = transliterator_transliterate("Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove; Lower();", $string); $string = preg_replace('/[-\s]+/', '-', $string); return trim($string, '-');}echo '/n'.slugify('A brmensch p hyeste niv! PHP! '); //out: a-ae-ubermensch-pa-hoyeste-niva!-i-a-lublu-php!-fiecho '/n'.slugify(' delgarm');//out: wb-farsy-dr-mjlh-dlgrm-delgarmecho '/n'.slugify(' ');//out: asbh-tsjyl-tlab-alsf-alawl-alktrwnyaa?>
function Example 2:
public static function slugify($string, $separator = null) { $separator = null !== $separator ? $separator : (null !== self::$separator ? self::$separator : '-'); $slug = trim(strip_tags($string)); $slug = transliterator_transliterate('NFD; [:Nonspacing Mark:] Remove; NFC; Any-Latin; Latin-ASCII; Lower();', $slug); $slug = preg_replace("/[^a-zA-Z0-9\\/_|+ -]/", '', $slug); $slug = preg_replace("/[\\/_|+ -]+/", $separator, $slug); $slug = trim($slug, $separator); return $slug; }
hotexamples - 30 Code Examples
slugify sample urls Delgarm
Original Link: https://dev.to/aradpardaz/php-create-slugify-url-from-all-language-to-english-229g
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To