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


PHP text::transliterate_to_ascii方法代碼示例

本文整理匯總了PHP中text::transliterate_to_ascii方法的典型用法代碼示例。如果您正苦於以下問題:PHP text::transliterate_to_ascii方法的具體用法?PHP text::transliterate_to_ascii怎麽用?PHP text::transliterate_to_ascii使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在text的用法示例。


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

示例1: clean

 /**
  * Transliterate UTF8 text to lowercase 7bit ASCII, 0-9a-z
  *
  * @param   string  $str
  * @return  string
  */
 public static function clean($str)
 {
     $str = mb_strtolower(text::strip_ascii_ctrl($str));
     if (!text::is_ascii($str)) {
         $str = strtolower(text::transliterate_to_ascii($str));
     }
     if (!text::is_ascii($str)) {
         $str = text::strip_non_ascii($str);
     }
     return $str;
     // return strtolower(iconv(Kohana::CHARSET, 'ASCII//TRANSLIT//IGNORE', $str));
 }
開發者ID:anqqa,項目名稱:Anqh,代碼行數:18,代碼來源:MY_utf8.php

示例2: transliterate_to_ascii

 /**
  * Tests the text::transliterate_to_ascii() function.
  * @dataProvider transliterate_to_ascii_provider
  * @group core.helpers.text.transliterate_to_ascii
  * @test
  */
 public function transliterate_to_ascii($str, $case, $expected_result)
 {
     $result = text::transliterate_to_ascii($str, $case);
     $this->assertEquals($expected_result, $result);
 }
開發者ID:BirenRathod,項目名稱:indicia-code,代碼行數:11,代碼來源:Helper_Text_Test.php

示例3: convert_filename_to_slug

 /**
  * Convert a filename into something we can use as a url component.
  * @param string $filename
  */
 static function convert_filename_to_slug($filename)
 {
     $result = str_replace("&", "-and-", $filename);
     $result = str_replace(" ", "-", $result);
     // It's not easy to extend the text helper since it's called by the Input class which is
     // referenced in hooks/init_gallery, so it's
     if (class_exists("transliterate")) {
         $result = transliterate::utf8_to_ascii($result);
     } else {
         $result = text::transliterate_to_ascii($result);
     }
     $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result);
     $result = preg_replace("/-+/", "-", $result);
     return trim($result, "-");
 }
開發者ID:qboy1987,項目名稱:mooiyou,代碼行數:19,代碼來源:item.php

示例4: title

 /**
  * Convert a phrase to a URL-safe title.
  *
  * @param   string  phrase to convert
  * @param   string  word separator (- or _)
  * @param   boolean  transliterate to ASCII
  * @return  string
  */
 public static function title($title, $separator = '-', $ascii_only = FALSE)
 {
     $separator = $separator === '-' ? '-' : '_';
     if ($ascii_only === TRUE) {
         // Replace accented characters by their unaccented equivalents
         $title = text::transliterate_to_ascii($title);
         // Remove all characters that are not the separator, a-z, 0-9, or whitespace
         $title = preg_replace('/[^' . $separator . 'a-z0-9\\s]+/', '', strtolower($title));
     } else {
         // Remove all characters that are not the separator, letters, numbers, or whitespace
         $title = preg_replace('/[^' . $separator . '\\pL\\pN\\s]+/u', '', mb_strtolower($title));
     }
     // Replace all separator characters and whitespace by a single separator
     $title = preg_replace('/[' . $separator . '\\s]+/', $separator, $title);
     // Trim separators from the beginning and end
     return trim($title, $separator);
 }
開發者ID:webmatter,項目名稱:gallery3-contrib,代碼行數:25,代碼來源:url.php


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