當前位置: 首頁>>代碼示例>>PHP>>正文


PHP transliterator_transliterate函數代碼示例

本文整理匯總了PHP中transliterator_transliterate函數的典型用法代碼示例。如果您正苦於以下問題:PHP transliterator_transliterate函數的具體用法?PHP transliterator_transliterate怎麽用?PHP transliterator_transliterate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了transliterator_transliterate函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: slugify

 /**
  * {@inheritdoc}
  */
 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;
 }
開發者ID:ersin-demirtas,項目名稱:EasySlugger,代碼行數:13,代碼來源:Utf8Slugger.php

示例2: slugify

 /**
  * {@inheritdoc}
  */
 public function slugify($string, $separator = null)
 {
     $separator = $separator ?: $this->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;
 }
開發者ID:basuritas-php,項目名稱:php-slugger,代碼行數:13,代碼來源:Utf8Slugger.php

示例3: slug

 /**
  * Return old good slug
  *
  * @param string       $string
  * @param string $replacement
  * @param bool   $lowercase
  *
  * @return string
  */
 public static function slug($string, $replacement = '-', $lowercase = true)
 {
     if (extension_loaded('intl') === true) {
         $options = 'Any-Latin; NFKD; [:Punctuation:] Remove; [^\\u0000-\\u007E] Remove';
         $string = transliterator_transliterate($options, $string);
         $string = preg_replace('/[-=\\s]+/', $replacement, $string);
     } else {
         $string = str_replace(array_keys(static::$transliteration), static::$transliteration, $string);
         $string = preg_replace('/[^\\p{L}\\p{Nd}]+/u', $replacement, $string);
     }
     $string = trim($string, $replacement);
     return $lowercase ? strtolower($string) : $string;
 }
開發者ID:gpis88ce,項目名稱:Gpis88ce,代碼行數:22,代碼來源:LittleBigHelper.php

示例4: transliterate

 public static function transliterate($string)
 {
     // needs intl extension
     if (function_exists('transliterator_transliterate')) {
         $string = transliterator_transliterate("Any-Latin; Latin-ASCII; [\\u0100-\\u7fff] remove", $string);
         $string = preg_replace('/[^\\pL\\d._]+/u', '-', $string);
         $string = preg_replace('/[-\\s]+/', '-', $string);
     } else {
         // uses iconv
         $string = preg_replace('~[^\\pL0-9_\\.]+~u', '-', $string);
         // substitutes anything but letters, numbers and '-' with separator
         $string = trim($string, '-');
         if (function_exists('iconv')) {
             $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string);
             // TRANSLIT does the whole job
         }
         $string = preg_replace('~[^-a-zA-Z0-9_\\.]+~', '', $string);
         // keep only letters, numbers, '_' and separator
     }
     $string = trim($string, '-');
     return $string;
 }
開發者ID:John-Eddy,項目名稱:ProjetCastor,代碼行數:22,代碼來源:Transliterator.php

示例5: formatReadableId

 protected function formatReadableId($id)
 {
     $id = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $id);
     $id = preg_replace('/([^a-z0-9])/iu', '-', $id);
     $id = preg_replace('/-+/u', '-', $id);
     $id = trim($id, '-');
     return $id;
 }
開發者ID:myurasov,項目名稱:mym-mongodb-odm-tools,代碼行數:8,代碼來源:ReadableIdTrait.php

示例6: transliterate

 private static function transliterate($string)
 {
     if (function_exists('transliterator_transliterate')) {
         $transString = transliterator_transliterate("Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; Lower();", $string);
     } else {
         $transString = static::toAscii($string);
     }
     return preg_replace('/[^A-Za-z0-9_.]/u', '', $transString);
 }
開發者ID:zwq,項目名稱:yii2_restful,代碼行數:9,代碼來源:Internet.php

示例7: transliterate

 public static function transliterate($string)
 {
     // the reason for using this rather "exotic" function in contrary to
     // iconv is, that iconv is very unstable. It relies on the correct
     // linked library, which means it works different on OSX than on Linux
     // also iconv + setlocale is not thread safe, so if you are using IIS
     // php-fpm, fastcgi or similar it can/will break
     return transliterator_transliterate('Any-Latin; Latin-ASCII; [\\u0100-\\u7fff] remove', $string);
 }
開發者ID:africc,項目名稱:php-epp2,代碼行數:9,代碼來源:Translit.php

示例8: transform

 public static function transform($string)
 {
     if (!function_exists('transliterator_transliterate') || !function_exists('transliterator_list_ids')) {
         return self::simpleTransform($string);
     }
     $transliteratorIds = transliterator_list_ids();
     if (!in_array('Any-Latin', $transliteratorIds) || !in_array('Latin-ASCII', $transliteratorIds)) {
         return self::simpleTransform($string);
     }
     return transliterator_transliterate('Any-Latin; Latin-ASCII; [\\u0100-\\u7fff] remove', $string);
 }
開發者ID:Umz,項目名稱:ImpressPages,代碼行數:11,代碼來源:Transliteration.php

示例9: generate

 /**
  * Creates a slug to be used for pretty URLs
  *
  * @param         $string
  * @param  string $delimiter
  * @return string
  */
 public static function generate($string, $delimiter = '-')
 {
     if (function_exists('transliterator_transliterate')) {
         $string = transliterator_transliterate('Any-Latin; Latin-ASCII; [:Punctuation:] Remove; Lower()', $string);
     } else {
         $string = mb_strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $string));
     }
     $string = preg_replace('/[-\\s]+/', $delimiter, $string);
     $string = preg_replace('/^[-\\s]+/', '', $string);
     $string = preg_replace('/[-\\s]+$/', '', $string);
     return trim($string, $delimiter);
 }
開發者ID:kjmtrue,項目名稱:phalcon-tip,代碼行數:19,代碼來源:Slug.php

示例10: slug

 /**
  * Return old good slug
  *
  * @param string       $string
  * @param string $replacement
  * @param bool   $lowercase
  *
  * @return string
  */
 public static function slug($string, $replacement = '-', $lowercase = true)
 {
     if (extension_loaded('intl') === true) {
         $options = 'Any-Latin; NFKD';
         $string = transliterator_transliterate($options, $string);
         $string = preg_replace('/[^a-zA-Z0-9=\\s—–-]+/u', '', $string);
         $string = preg_replace('/[=\\s—–-]+/u', $replacement, $string);
     } else {
         $string = str_replace(array_keys(static::$transliteration), static::$transliteration, $string);
         $string = preg_replace('/[^\\p{L}\\p{Nd}]+/u', $replacement, $string);
     }
     $string = trim($string, $replacement);
     return $lowercase ? strtolower($string) : $string;
 }
開發者ID:webvimark,項目名稱:helpers,代碼行數:23,代碼來源:LittleBigHelper.php

示例11: transformForSeo

 /**
  * {@inheritDoc}
  */
 public function transformForSeo($services = null)
 {
     if (null == $services) {
         return "";
     }
     if (!($services instanceof \ArrayAccess or is_array($services) or $services instanceof \Traversable or $services instanceof \Countable)) {
         throw new \InvalidArgumentException('The given argument must be array accessible');
     }
     $servicesSlug = array();
     foreach ($services as $service) {
         $servicesSlug[] = str_replace(' ', '', transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $service->getName()));
     }
     return count($servicesSlug) ? implode('+', $servicesSlug) : 'noservices';
 }
開發者ID:blab2015,項目名稱:seh,代碼行數:17,代碼來源:ServicesToStringTransformer.php

示例12: toAscii

 /**
  * Convert to ASCII.
  *
  * @since 150424 Multibyte support.
  *
  * @param mixed $value Any input value.
  *
  * @return string|array|object Output value.
  */
 public function toAscii($value)
 {
     if (is_array($value) || is_object($value)) {
         foreach ($value as $_key => &$_value) {
             $_value = $this->toAscii($_value);
         }
         // unset($_key, $_value);
         return $value;
     }
     if (!($string = (string) $value)) {
         return $string;
         // Nothing to do.
     }
     return (string) transliterator_transliterate('Any-Latin; Latin-ASCII', $string);
 }
開發者ID:websharks,項目名稱:core,代碼行數:24,代碼來源:Transliterate.php

示例13: transliterate

 public static function transliterate($string, $options = ['UPPER'])
 {
     $op = '';
     if (array_key_exists('UPPER', $options) || in_array('UPPER', $options)) {
         $op = '; Upper()';
     }
     if (array_key_exists('LOWER', $options) || in_array('LOWER', $options)) {
         $op = '; Lower()';
     }
     //$string = mb_convert_case($string, MB_CASE_UPPER, "UTF-8");
     $string = transliterator_transliterate('Any-Latin; Latin-ASCII; [\\u0100-\\u7fff] remove' . $op, $string);
     $string = trim($string);
     // TODO verify if we should remove -
     //$string = str_replace('-','',$string);
     return $string;
 }
開發者ID:winponta,項目名稱:helpers,代碼行數:16,代碼來源:StringHelper.php

示例14: filter

 /**
  * @param mixed $value
  * @param string $replaceChar
  * @return string
  */
 public function filter($value, $replaceChar = '-')
 {
     // Setting en_US locale to replace diacritic characters.
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     // Do not filter non-string values
     if (!is_string($value)) {
         return $value;
     }
     $string = str_replace(array('&', '&'), 'and', $value);
     $string = transliterator_transliterate('Any-Latin;Latin-ASCII;', $string);
     $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
     $string = preg_replace('/[^a-z0-9]+/i', $replaceChar, $string);
     $string = preg_replace('/\\_+/', $replaceChar, $string);
     $string = trim($string, $replaceChar);
     $string = strtolower($string);
     return $string;
 }
開發者ID:webowy,項目名稱:zend-filter,代碼行數:22,代碼來源:Normalize.php

示例15: strip_diacriticals

function strip_diacriticals($in)
{
    if (function_exists('transliterator_transliterate')) {
        // PHP 5.4 + intl
        return transliterator_transliterate('Any-Latin; Latin-ASCII', $in);
    }
    if (function_exists('normalizer_normalize')) {
        // PHP 5.3 + intl
        return normalizer_normalize(preg_replace('/\\p{Mn}+/u', '', normalizer_normalize($in, Normalizer::FORM_D)), Normalizer::FORM_C);
    }
    if (function_exists('iconv') && ICONV_IMPL == 'glibc') {
        return iconv('UTF-8', 'ASCII//TRANSLIT', $in);
    }
    // version incomplète (limitée au latin1)
    $patterns = array('~&([A-za-z])(?:grave|acute|circ|tilde|uml|ring|cedil|slash|caron);~' => '\\1', '~&([A-za-z]{2})lig;~' => '\\1', '~&[^;]+;~' => '');
    $out = htmlentities($in, ENT_NOQUOTES, 'UTF-8');
    $out = preg_replace(array_keys($patterns), array_values($patterns), $out);
    return $out;
}
開發者ID:jacquesmattheij,項目名稱:SRS,代碼行數:19,代碼來源:learn.php


注:本文中的transliterator_transliterate函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。