本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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, '');
}
}