当前位置: 首页>>代码示例>>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;未经允许,请勿转载。