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


PHP utf8::str_ireplace方法代碼示例

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


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

示例1: normalize

 public static function normalize($string, $encoding = 'utf-8')
 {
     $string = iconv($encoding, 'ascii//translit', $string);
     $string = utf8::str_ireplace(',', '', $string);
     $string = utf8::str_ireplace('\'', '', $string);
     $string = preg_replace('/[^a-z0-9-\\+\\/_ ]/iUD', '_', $string);
     return $string;
 }
開發者ID:TdroL,項目名稱:piotrszkaluba.pl,代碼行數:8,代碼來源:text.php

示例2: __normalize_filename

 public static function __normalize_filename($filename)
 {
     $encoding = 'utf-8';
     $name = pathinfo($filename, PATHINFO_FILENAME);
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     $name = iconv($encoding, 'ascii//translit', $name);
     $name = utf8::str_ireplace(',', '', $name);
     $name = utf8::str_ireplace('\'', '', $name);
     $name = preg_replace('/[^a-z0-9\\-_\\$\\.\\+\\!\\(\\)]/i', '_', $name);
     return preg_replace('/_{2,}/i', '_', $name) . '.' . $ext;
 }
開發者ID:TdroL,項目名稱:kohana-jelly-torn,代碼行數:11,代碼來源:file.php

示例3: _str_ireplace

/**
 * utf8::str_ireplace
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _str_ireplace($search, $replace, $str, &$count = NULL)
{
    if (utf8::is_ascii($search) and utf8::is_ascii($replace) and utf8::is_ascii($str)) {
        return str_ireplace($search, $replace, $str, $count);
    }
    if (is_array($str)) {
        foreach ($str as $key => $val) {
            $str[$key] = utf8::str_ireplace($search, $replace, $val, $count);
        }
        return $str;
    }
    if (is_array($search)) {
        $keys = array_keys($search);
        foreach ($keys as $k) {
            if (is_array($replace)) {
                if (array_key_exists($k, $replace)) {
                    $str = utf8::str_ireplace($search[$k], $replace[$k], $str, $count);
                } else {
                    $str = utf8::str_ireplace($search[$k], '', $str, $count);
                }
            } else {
                $str = utf8::str_ireplace($search[$k], $replace, $str, $count);
            }
        }
        return $str;
    }
    $search = utf8::strtolower($search);
    $str_lower = utf8::strtolower($str);
    $total_matched_strlen = 0;
    $i = 0;
    while (preg_match('/(.*?)' . preg_quote($search, '/') . '/s', $str_lower, $matches)) {
        $matched_strlen = strlen($matches[0]);
        $str_lower = substr($str_lower, $matched_strlen);
        $offset = $total_matched_strlen + strlen($matches[1]) + $i * (strlen($replace) - 1);
        $str = substr_replace($str, $replace, $offset, strlen($search));
        $total_matched_strlen += $matched_strlen;
        $i++;
    }
    $count += $i;
    return $str;
}
開發者ID:kjgarza,項目名稱:ushahidi,代碼行數:50,代碼來源:str_ireplace.php

示例4: account_number

 public function account_number($p_iNRB)
 {
     // Usuniecie spacji
     $iNRB = utf8::str_ireplace(' ', '', $p_iNRB);
     // Sprawdzenie czy przekazany numer zawiera 26 znaków
     if (utf8::strlen($iNRB) != 26) {
         die('fail #1');
         return false;
     }
     // Zdefiniowanie tablicy z wagami poszczególnych cyfr
     $aWagiCyfr = array(1, 10, 3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62, 38, 89, 17, 73, 51, 25, 56, 75, 71, 31, 19, 93, 57);
     // Dodanie kodu kraju (w tym przypadku dodajemy kod PL)
     $iNRB = $iNRB . '2521';
     $iNRB = utf8::substr($iNRB, 2) . utf8::substr($iNRB, 0, 2);
     // Wyzerowanie zmiennej
     $iSumaCyfr = 0;
     // Pćtla obliczająca sumć cyfr w numerze konta
     for ($i = 0; $i < 30; $i++) {
         $iSumaCyfr += $iNRB[29 - $i] * $aWagiCyfr[$i];
     }
     // Sprawdzenie czy modulo z sumy wag poszczegolnych cyfr jest rowne 1
     return $iSumaCyfr % 97 == 1;
 }
開發者ID:TdroL,項目名稱:hurtex,代碼行數:23,代碼來源:validate.php

示例5: random

 /**
  * Tests the text::random() function.
  * @dataProvider random_provider
  * @group core.helpers.text.random
  * @test
  */
 public function random($type, $length = 8)
 {
     //$this->markTestIncomplete('Test for PHP 5.3 bug needs to be counted, Kohana is still supporting 5.2');
     $result = text::random($type, $length);
     if ((string) $type) {
         // Checking length
         $this->assertEquals(mb_strlen($result), $length);
         $pool = '';
         switch ($type) {
             case 'alnum':
                 $this->assertTrue(valid::alpha_numeric($result));
                 break;
             case 'alpha':
                 $this->assertTrue(valid::alpha($result));
                 break;
             case 'numeric':
                 $this->assertTrue(valid::numeric($result));
                 break;
             case 'nozero':
                 $this->assertTrue(is_numeric($result));
                 break;
             case 'hexdec':
                 $pool = '0123456789abcdef';
                 break;
             case 'distinct':
                 $pool = '2345679ACDEFHJKLMNPRSTUVWXYZ';
                 break;
             default:
                 $pool = (string) $type;
         }
         if ($pool) {
             // PHP versions before 5.3 have a bug with preg_quote and it doesn't escape '-'
             $pool = version_compare(PHP_VERSION, '5.3', '>=') ? preg_quote((string) $pool, '/') : utf8::str_ireplace('-', '\\-', preg_quote((string) $pool, '/'));
             if (preg_match('/[' . $pool . ']*/u', $result, $match)) {
                 $this->assertEquals($match[0], $result);
             } else {
                 $this->assertTrue(FALSE);
             }
         }
     } else {
         // Checking length
         $this->assertEquals($result, '');
     }
 }
開發者ID:BirenRathod,項目名稱:indicia-code,代碼行數:50,代碼來源:Helper_Text_Test.php


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