当前位置: 首页>>代码示例>>PHP>>正文


PHP utf8_ireplace函数代码示例

本文整理汇总了PHP中utf8_ireplace函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_ireplace函数的具体用法?PHP utf8_ireplace怎么用?PHP utf8_ireplace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了utf8_ireplace函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: str_ireplace

 public static function str_ireplace($search, $replace, $str, $count = null)
 {
     mimport('phputf8.str_ireplace');
     if ($count === false) {
         return utf8_ireplace($search, $replace, $str);
     } else {
         return utf8_ireplace($search, $replace, $str, $count);
     }
 }
开发者ID:vanie3,项目名称:appland,代码行数:9,代码来源:string.php

示例2: utf8_ireplace

/**
* UTF-8 aware alternative to str_ireplace
* Case-insensitive version of str_replace
* Note: requires utf8_strtolower
* Note: it's not fast and gets slower if $search / $replace is array
* Notes: it's based on the assumption that the lower and uppercase
* versions of a UTF-8 character will have the same length in bytes
* which is currently true given the hash table to strtolower
* @param string
* @return string
* @see http://www.php.net/str_ireplace
* @see utf8_strtolower
* @package utf8
* @subpackage strings
*/
function utf8_ireplace($search, $replace, $str, $count = NULL){
    
    if ( !is_array($search) ) {
        
        $slen = strlen($search);
        if ( $slen == 0 ) {
            return $str;
        }
        
        $lendif = strlen($replace) - strlen($search);
        $search = utf8_strtolower($search);
        
        $search = preg_quote($search);
        $lstr = utf8_strtolower($str);
        $i = 0;
        $matched = 0;
        while ( preg_match('/(.*)'.$search.'/Us',$lstr, $matches) ) {
            if ( $i === $count ) {
                break;
            }
            $mlen = strlen($matches[0]);
            $lstr = substr($lstr, $mlen);
            $str = substr_replace($str, $replace, $matched+strlen($matches[1]), $slen);
            $matched += $mlen + $lendif;
            $i++;
        }
        return $str;
        
    } else {
        
        foreach ( array_keys($search) as $k ) {
            
            if ( is_array($replace) ) {
                
                if ( array_key_exists($k,$replace) ) {
                    
                    $str = utf8_ireplace($search[$k], $replace[$k], $str, $count);
                    
                } else {
                
                    $str = utf8_ireplace($search[$k], '', $str, $count);
                    
                }
                
            } else {
            
                $str = utf8_ireplace($search[$k], $replace, $str, $count);
                
            }
        }
        return $str;
        
    }

}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:70,代码来源:str_ireplace.php

示例3: str_ireplace

 /**
  * UTF-8 aware alternative to str_ireplace
  * Case-insensitive version of str_replace
  *
  * @static
  * @access public
  * @param string string to search
  * @param string existing string to replace
  * @param string new string to replace with
  * @param int optional count value to be passed by referene
  * @see http://www.php.net/str_ireplace
  */
 public static function str_ireplace($search, $replace, $str, $count = NULL)
 {
     jimport('phputf8.str_ireplace');
     if ($count === FALSE) {
         return utf8_ireplace($search, $replace, $str);
     } else {
         return utf8_ireplace($search, $replace, $str, $count);
     }
 }
开发者ID:joebushi,项目名称:joomla,代码行数:21,代码来源:string.php

示例4: str_ireplace

 /**
  * UTF-8 aware alternative to str_ireplace
  * Case-insensitive version of str_replace
  *
  * @param   string   $search   String to search
  * @param   string   $replace  Existing string to replace
  * @param   string   $str      New string to replace with
  * @param   integer  $count    Optional count value to be passed by reference
  *
  * @return  string  UTF-8 String
  *
  * @see     http://www.php.net/str_ireplace
  * @since   2.0
  */
 public static function str_ireplace($search, $replace, $str, $count = null)
 {
     if (!function_exists('utf8_ireplace')) {
         require_once __DIR__ . '/phputf8/str_ireplace.php';
     }
     if ($count === null) {
         return utf8_ireplace($search, $replace, $str);
     }
     return utf8_ireplace($search, $replace, $str, $count);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:24,代码来源:Utf8String.php

示例5: str_ireplace

 /**
  * UTF-8 aware alternative to str_ireplace
  * Case-insensitive version of str_replace
  *
  * @param   string   $search   String to search
  * @param   string   $replace  Existing string to replace
  * @param   string   $str      New string to replace with
  * @param   integer  $count    Optional count value to be passed by referene
  *
  * @return  string  UTF-8 String
  *
  * @see     http://www.php.net/str_ireplace
  * @since   1.0
  */
 public static function str_ireplace($search, $replace, $str, $count = null)
 {
     require_once __DIR__ . '/phputf8/str_ireplace.php';
     if ($count === false) {
         return utf8_ireplace($search, $replace, $str);
     }
     return utf8_ireplace($search, $replace, $str, $count);
 }
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:22,代码来源:String.php

示例6: upp_mangle_filename

function upp_mangle_filename($file_name)
{
    /* remove internal dots (cosmetical, it would be done by WP, but we need to display it :)*/
    $ext = upp_findexts($file_name);
    $file_name = str_replace("." . $ext, "", $file_name);
    $file_name = str_replace(".", "", $file_name);
    // initial cleaning
    $file_name = str_replace("(", "", $file_name);
    $file_name = str_replace(")", "", $file_name);
    $file_name = str_replace("'", "", $file_name);
    $file_name = str_replace('"', "", $file_name);
    $file_name = str_replace(',', "", $file_name);
    // some language-based prefilter. props denis.
    $de_from = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü');
    $de_to = array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue');
    $file_name = str_replace($de_from, $de_to, $file_name);
    $utf8ornot = get_option('uploadplus_utf8toascii');
    if ($utf8ornot[0] == 1) {
        $file_name = utf8_to_ascii($file_name);
    }
    $file_name = $file_name . "." . $ext;
    $lettercase = get_option('uploadplus_case');
    switch ($lettercase[0]) {
        case "1":
            $file_name = utf8_strtolower($file_name);
            break;
        case "2":
            $file_name = utf8_strtoupper($file_name);
            break;
    }
    $y = get_option('uploadplus_cleanlevel');
    switch ($y[0]) {
        case "1":
            $file_name = ereg_replace("[^A-Za-z0-9._]", "-", $file_name);
            $file_name = utf8_ireplace("_", "-", $file_name);
            $file_name = utf8_ireplace(" ", "-", $file_name);
            $file_name = utf8_ireplace("%20", "-", $file_name);
            break;
        case "2":
            $file_name = ereg_replace("[^A-Za-z0-9._]", "", $file_name);
            $file_name = utf8_ireplace("_", "", $file_name);
            $file_name = utf8_ireplace("-", "", $file_name);
            $file_name = utf8_ireplace("%20", "", $file_name);
            break;
        case "3":
            $file_name = ereg_replace("[^A-Za-z0-9._]", "_", $file_name);
            $file_name = utf8_ireplace("-", "_", $file_name);
            $file_name = utf8_ireplace(" ", "_", $file_name);
            $file_name = utf8_ireplace("%20", "_", $file_name);
            break;
    }
    $sep = $y[0] == '1' ? "-" : "";
    if (!$sep) {
        $sep = $y[0] == '3' ? "_" : "";
    }
    $standard = get_option('uploadplus_prefix');
    switch ($standard) {
        case "0":
            $file_name = date('d') . $sep . $file_name;
            break;
        case "1":
            $file_name = date('md') . $sep . $file_name;
            break;
        case "2":
            $file_name = date('ymd') . $sep . $file_name;
            break;
        case "3":
            $file_name = date('Ymd') . $sep . $file_name;
            break;
        case "4":
            $file_name = date('YmdHi') . $sep . $file_name;
            break;
        case "5":
            $file_name = date('YmdHis') . $sep . $file_name;
            break;
        case "6":
            $file_name = date('U') . $sep . $file_name;
            break;
        case "7":
            $file_name = mt_rand() . $sep . $file_name;
            break;
        case "8":
            $file_name = md5(mt_rand()) . $sep . $file_name;
            break;
        case "9":
            $file_name = str_replace(array(".", "_", "-", " "), $sep, utf8_to_ascii(get_bloginfo('name'))) . $sep . $file_name;
            break;
        case "A":
            $file_name = str_replace(array(".", "_", "-", " "), "", utf8_to_ascii(get_bloginfo('name'))) . $sep . $file_name;
            break;
    }
    return $file_name;
}
开发者ID:Jintha,项目名称:cama,代码行数:93,代码来源:uploadplus.php

示例7: testReplaceLinefeedSearch

 function testReplaceLinefeedSearch()
 {
     $str = "Iñtërnâtiônàli\nzætiøn";
     $replaced = "Iñtërnâtiônàlisetiøn";
     $this->assertEqual(utf8_ireplace("lI\nzÆ", 'lise', $str), $replaced);
 }
开发者ID:kidwellj,项目名称:scuttle,代码行数:6,代码来源:utf8_str_ireplace.test.php

示例8: str_ireplace

 /**
  * UTF-8 aware alternative to str_ireplace()
  *
  * Case-insensitive version of str_replace()
  *
  * @param   string   $search   String to search
  * @param   string   $replace  Existing string to replace
  * @param   string   $str      New string to replace with
  * @param   integer  $count    Optional count value to be passed by referene
  *
  * @return  string  UTF-8 String
  *
  * @see     http://www.php.net/str_ireplace
  * @since   1.3.0
  */
 public static function str_ireplace($search, $replace, $str, $count = null)
 {
     if ($count === false) {
         return utf8_ireplace($search, $replace, $str);
     }
     return utf8_ireplace($search, $replace, $str, $count);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:22,代码来源:StringHelper.php

示例9: utf8_str_ireplace

 function utf8_str_ireplace($search, $replace, $subject, $count = null)
 {
     return utf8_ireplace($search, $replace, $subject, $count);
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:4,代码来源:utf8.php


注:本文中的utf8_ireplace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。