本文整理汇总了PHP中iconv_strrpos函数的典型用法代码示例。如果您正苦于以下问题:PHP iconv_strrpos函数的具体用法?PHP iconv_strrpos怎么用?PHP iconv_strrpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iconv_strrpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIconvStrPos
/**
* @covers Symfony\Polyfill\Iconv\Iconv::iconv_strpos
* @covers Symfony\Polyfill\Iconv\Iconv::iconv_strrpos
*/
public function testIconvStrPos()
{
$this->assertSame(1, iconv_strpos('11--', '1-', 0, 'UTF-8'));
$this->assertSame(2, iconv_strpos('-11--', '1-', 0, 'UTF-8'));
$this->assertSame(false, iconv_strrpos('한국어', '', 'UTF-8'));
$this->assertSame(1, iconv_strrpos('한국어', '국', 'UTF-8'));
}
示例2: _strrpos
function _strrpos($str, $search, $offset = null)
{
if (is_null($offset)) {
$old_enc = $this->_setUTF8IconvEncoding();
$result = iconv_strrpos($str, $search);
$this->_setIconvEncoding($old_enc);
return $result;
} else {
//mb_strrpos doesn't support offset! :(
return parent::_strrpos($str, $search, (int) $offset);
}
}
示例3: wordWrap
/**
* Word wrap
*
* @param string $string
* @param integer $width
* @param string $break
* @param boolean $cut
* @param string $charset
* @return string
*/
public static function wordWrap($string, $width = 75, $break = "\n", $cut = false, $charset = 'UTF-8')
{
$result = array();
while (($stringLength = iconv_strlen($string, $charset)) > 0) {
$subString = iconv_substr($string, 0, $width, $charset);
if ($subString === $string) {
$cutLength = null;
} else {
$nextChar = iconv_substr($string, $width, 1, $charset);
if ($nextChar === ' ' || $nextChar === $break) {
$afterNextChar = iconv_substr($string, $width + 1, 1, $charset);
if ($afterNextChar === false) {
$subString .= $nextChar;
}
$cutLength = iconv_strlen($subString, $charset) + 1;
} else {
$spacePos = iconv_strrpos($subString, ' ', $charset);
if ($spacePos !== false) {
$subString = iconv_substr($subString, 0, $spacePos, $charset);
$cutLength = $spacePos + 1;
} else {
if ($cut === false) {
$spacePos = iconv_strpos($string, ' ', 0, $charset);
if ($spacePos !== false) {
$subString = iconv_substr($string, 0, $spacePos, $charset);
$cutLength = $spacePos + 1;
} else {
$subString = $string;
$cutLength = null;
}
} else {
$breakPos = iconv_strpos($subString, $break, 0, $charset);
if ($breakPos !== false) {
$subString = iconv_substr($subString, 0, $breakPos, $charset);
$cutLength = $breakPos + 1;
} else {
$subString = iconv_substr($subString, 0, $width, $charset);
$cutLength = $width;
}
}
}
}
}
$result[] = $subString;
if ($cutLength !== null) {
$string = iconv_substr($string, $cutLength, $stringLength - $cutLength, $charset);
} else {
break;
}
}
return implode($break, $result);
}
示例4: foo
function foo($haystk, $needle, $to_charset = false, $from_charset = false)
{
if ($from_charset !== false) {
$haystk = iconv($from_charset, $to_charset, $haystk);
}
if ($to_charset !== false) {
var_dump(iconv_strlen($haystk, $to_charset));
var_dump(iconv_strrpos($haystk, $needle, $to_charset));
} else {
var_dump(iconv_strlen($haystk));
var_dump(iconv_strrpos($haystk, $needle));
}
}
示例5: strrpos
/**
* Here used as a multibyte enabled equivalent of `strrpos()`.
*
* @link http://php.net/function.iconv-strpos.php
* @param string $haystack
* @param string $needle
* @return integer|boolean
*/
public function strrpos($haystack, $needle)
{
return iconv_strrpos($haystack, $needle, 'UTF-8');
}
示例6: dle_strrpos
function dle_strrpos($str, $needle, $charset)
{
if (strtolower($charset) == "utf-8") {
return iconv_strrpos($str, $needle, "utf-8");
} else {
return strrpos($str, $needle);
}
}
示例7: utf8_strrpos
/**
* Find position of last occurrence of a char in a string, both arguments are in UTF-8.
*
* @param string $haystack UTF-8 string to search in
* @param string $needle UTF-8 character to search for (single character)
* @return int The character position
* @see strrpos()
*/
public function utf8_strrpos($haystack, $needle)
{
if ($this->getConversionStrategy() === self::STRATEGY_MBSTRING) {
return mb_strrpos($haystack, $needle, 'utf-8');
} elseif ($this->getConversionStrategy() === self::STRATEGY_ICONV) {
return iconv_strrpos($haystack, $needle, 'utf-8');
}
$byte_pos = strrpos($haystack, $needle);
if ($byte_pos === false) {
// Needle not found
return false;
}
return $this->utf8_byte2char_pos($haystack, $byte_pos);
}
示例8: utf8_strrpos
/**
* Find position of last occurrence of a char in a string, both arguments are in UTF-8.
*
* @param string $haystack UTF-8 string to search in
* @param string $needle UTF-8 character to search for (single character)
* @return int The character position
* @see strrpos()
*/
public function utf8_strrpos($haystack, $needle)
{
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] === 'mbstring') {
return mb_strrpos($haystack, $needle, 'utf-8');
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] === 'iconv') {
return iconv_strrpos($haystack, $needle, 'utf-8');
}
$byte_pos = strrpos($haystack, $needle);
if ($byte_pos === FALSE) {
// Needle not found
return FALSE;
}
return $this->utf8_byte2char_pos($haystack, $byte_pos);
}
示例9: unset
//get an unset variable
$unset_var = 10;
unset($unset_var);
// get a class
class classA
{
public function __toString()
{
return "world";
}
}
// heredoc string
$heredoc = <<<EOT
world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $needle argument
$inputs = array(0, 1, 12345, -2345, 10.5, -10.5, 123456789000.0, 1.23456789E-9, 0.5, NULL, null, true, false, TRUE, FALSE, "", '', "world", 'world', $heredoc, new classA(), @$undefined_var, @$unset_var, $fp);
// loop through each element of $inputs to check the behavior of iconv_strrpos()
$iterator = 1;
foreach ($inputs as $input) {
echo "\n-- Iteration {$iterator} --\n";
var_dump(iconv_strrpos($haystack, $input, $encoding));
$iterator++;
}
fclose($fp);
echo "Done";
?>
示例10: grapheme_position
protected static function grapheme_position($s, $needle, $offset, $mode)
{
if ($offset > 0) {
$s = (string) self::grapheme_substr($s, $offset);
} else {
if ($offset < 0) {
$offset = 0;
}
}
if ('' === (string) $needle) {
return false;
}
if ('' === (string) $s) {
return false;
}
switch ($mode) {
case 0:
$needle = iconv_strpos($s, $needle, 0, 'UTF-8');
break;
case 1:
$needle = mb_stripos($s, $needle, 0, 'UTF-8');
break;
case 2:
$needle = iconv_strrpos($s, $needle, 'UTF-8');
break;
default:
$needle = mb_strripos($s, $needle, 0, 'UTF-8');
break;
}
return $needle ? self::grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8')) + $offset : $needle;
}
示例11: search
function search()
{
if ($this->status) {
$q = "SELECT * FROM sum_base WHERE userid = " . $this->sum_user['id'] . " ORDER BY `date` DESC";
?>
<script>
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}
function actpay(x){
$.jAlert({
'title': 'Проверьте данные:',
'content': Base64.decode(x),
'theme': 'green',
'showAnimation': 'fadeInUp'
});
}
function pay(y){
$.jAlert({
'title': 'Скачать Д/К:',
'content': '<span class="filter"><a class="c3" target="_blank" href="test2.php?id='+y+'">Д/К (21 знак)</a> <a class="c1" target="_blank" href="test3.php?id='+y+'">Д/К (15 знаков)</a></span>',
'theme': 'green',
'showAnimation': 'fadeInUp'
});
}
function delit(z){
$.jAlert({
'title': 'Удалить Д/К:',
'content': '<center>Вы действительно хотите удалить Д/К? </center><div class="ja_btn_wrap optBack"><a href="?delete&id='+z+'" class="ja_btn ja_btn_default">Удалить</a> </div>',
'theme': 'green',
'showAnimation': 'fadeInUp'
});
}
</script>
<?php
$res = mysql_query($q);
echo '<br>
<div style="width: 90%; margin: auto; vertical-align: top;">
<div style="width: 40%; float: left; vertical-align: top; margin-top: -5px; margin-bottom: 10px;" class="filter">
<a class="btn btn-warning active" href="?filter&from=' . strtotime(date('Y-m-01')) . '&to=' . strtotime(date('Y-m-15')) . '">1-15 числа</a>
<a class="btn btn-warning active" href="?filter&from=' . strtotime(date('Y-m-15')) . '&to=' . strtotime(date('Y-m-31')) . '">15-31 числа</a>
<a class="btn btn-warning active" href="?myorder">Все заявки</a>
</div>
<div style="width: 50%; float: right; text-align: right; vertical-align: top;">
<form method="post" class="qwa" action="?search"><input type="text" required="" name="key"><button class="registration_button btn btn-success najti">Найти</button></form>
</div></div><br>';
echo '<br><table class="owned" width="90%" style="margin: auto;">';
echo '<tr>
<td><b>№</b></td>
<td><b><i class="glyphicon glyphicon-user"></i> ФИО заявителя</b></td>
<td><b><i class="glyphicon glyphicon-list-alt"></i> Транспортное средство</b></td>
<td><b><i class="glyphicon glyphicon-barcode"></i> Номер кузова</b></td>
<td><b><i class="glyphicon glyphicon-calendar"></i> Год выпуска</b></td>
<td><b><i class="glyphicon glyphicon-barcode"></i> Код ЕАИСТО</b></td>
<td><b><i class="glyphicon glyphicon-time"></i> Срок</b></td>
<td><b><i class="glyphicon glyphicon-shopping-cart"></i> Стоимость</b></td>
<td><b><i class="glyphicon glyphicon-info-sign"></i> Статус</b></td>
<td><b><i class="glyphicon glyphicon-calendar"></i> Дата</b></td>
<td><b>Операции</b></td>
</tr>';
while ($row = mysql_fetch_array($res)) {
$allstring = $row['field1'] . ' ' . $row['field2'] . ' ' . $row['field3'] . ' ' . $row['field6'] . ' ' . $row['field7'] . ' ' . $row['field5'] . ' ' . $row['field11'] . ' ' . $row['longg'] . ' ' . $row['price'];
$allstring = mb_strtoupper($allstring, 'UTF-8');
if (iconv_strrpos($allstring, mb_strtoupper($_POST['key'], 'UTF-8'), 'UTF-8')) {
$qqq = 'true';
} else {
$qqq = 'false';
}
if ($qqq == 'true') {
$tormoz = str_replace("Hydraulic", "Гидравлический", $row['field16']);
$tormoz = str_replace("Pneumatic", "Пневматический", $tormoz);
$tormoz = str_replace("Mechanical", "Механический", $tormoz);
$tormoz = str_replace("Combined", "Комбинированный", $tormoz);
$tormoz = str_replace("None", "Отстутствует", $tormoz);
$petrol = str_replace("Petrol", "Бензин", $row['field17']);
$petrol = str_replace("Diesel", "Дизельное топливо", $petrol);
$petrol = str_replace("PressureGas", "Сжатый газ", $petrol);
$petrol = str_replace("LiquefiedGas", "Сжиженный газ", $petrol);
$petrol = str_replace("None", "Без топлива", $petrol);
$formed = '
<b>ФИО:</b> ' . $row['field1'] . ' ' . $row['field2'] . ' ' . $row['field3'] . '<br>
<b>Гос. номер:</b> ' . $row['field4'] . '<br>
<b>VIN:</b> ' . $row['field5'] . '<br>
<b>Авто:</b> ' . $row['field6'] . ' ' . $row['field7'] . '<br>
<b>Год выпуска:</b> ' . $row['field11'] . '<br>
<b>Шасси/рама:</b> ' . $row['field12'] . '<br>
<b>Кузов:</b> ' . $row['field13'] . '<br>
<b>Масса / (макс.):</b> ' . $row['field15'] . ' / ' . $row['field14'] . '<br>
<b>Тормозная система:</b> ' . $tormoz . '<br>
<b>Топливо:</b> ' . $petrol . '<br>
<b>Пробег:</b> ' . $row['field18'] . '<br>
<b>Шины:</b> ' . $row['field19'] . '<br>
<b>Серия, номер документа:</b> ' . $row['field23'] . ' ' . $row['field24'] . '<br>
<b>Кем выдан:</b> ' . $row['field26'] . '<br>
<b>Цена:</b> ' . $row['price'] . '
<div class="ja_btn_wrap optBack"><a class="ja_btn ja_btn_default" href="?payit&id=' . $row['id'] . '">Оплатить</a> </div>
';
$formed = "'" . base64_encode($formed) . "'";
if ($row['payeed'] == '1') {
$ispayeed = 'Оплачено';
$linkpay = '
<a onclick="pay(' . $row['id'] . '); return false;" href="?iedown&forieid=' . $row['id'] . '" class="btn btn-primary btn-sm save_pdf"><span class="glyphicon glyphicon-download-alt"></span> Скачать Д/К</a>';
//.........这里部分代码省略.........
示例12: mb_strrpos
function mb_strrpos($haystack, $needle, $encoding = '')
{
$encoding = $this->regularize_encoding($encoding);
if ($this->use_iconv) {
return iconv_strrpos($haystack, $needle, $encoding);
} else {
switch ($e = $this->mbemu_internals['encoding'][$encoding]) {
case 1:
//euc-jp
//euc-jp
case 2:
//shift-jis
//shift-jis
case 4:
//utf-8
//utf-8
case 5:
//utf-16
//utf-16
case 8:
//utf16BE
preg_match_all('/' . $this->mbemu_internals['regex'][$e] . '/', $haystack, $ar_h);
preg_match_all('/' . $this->mbemu_internals['regex'][$e] . '/', $needle, $ar_n);
return $this->_sub_strrpos($ar_h[0], $ar_n[0]);
case 3:
//jis
$haystack = $this->mb_convert_encoding($haystack, 'SJIS', 'JIS');
$needle = $this->mb_convert_encoding($needle, 'SJIS', 'JIS');
preg_match_all('/' . $this->mbemu_internals['regex'][2] . '/', $haystack, $ar_h);
preg_match_all('/' . $this->mbemu_internals['regex'][2] . '/', $needle, $ar_n);
return $this->_sub_strrpos($ar_h[0], $ar_n[0]);
case 0:
//ascii
//ascii
case 6:
//iso-8859-1
//iso-8859-1
default:
return strrpos($haystack, $needle);
}
}
}
示例13: grapheme_position
private static function grapheme_position($s, $needle, $offset, $mode)
{
if (!preg_match('/./us', $needle .= '')) {
return false;
}
if (!preg_match('/./us', $s .= '')) {
return false;
}
if ($offset > 0) {
$s = self::grapheme_substr($s, $offset);
} elseif ($offset < 0) {
if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID < 50535 || 50600 <= PHP_VERSION_ID && PHP_VERSION_ID < 50621 || 70000 <= PHP_VERSION_ID && PHP_VERSION_ID < 70006) {
$offset = 0;
} else {
return false;
}
}
switch ($mode) {
case 0:
$needle = iconv_strpos($s, $needle, 0, 'UTF-8');
break;
case 1:
$needle = mb_stripos($s, $needle, 0, 'UTF-8');
break;
case 2:
$needle = iconv_strrpos($s, $needle, 'UTF-8');
break;
default:
$needle = mb_strripos($s, $needle, 0, 'UTF-8');
break;
}
return $needle ? self::grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8')) + $offset : $needle;
}
示例14: nv_strrpos
/**
* nv_strrpos()
*
* @param mixed $haystack
* @param mixed $needle
* @param integer $offset
* @return
*/
function nv_strrpos($haystack, $needle, $offset = 0)
{
global $global_config;
return iconv_strrpos($haystack, $needle, $offset, $global_config['site_charset']);
}
示例15: iconv_strrpos
<?php
/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset])
* Description: Find position of last occurrence of a string within another
* Source code: ext/iconv/iconv.c
*/
/*
* Pass iconv_strrpos() an encoding that doesn't exist
*/
echo "*** Testing iconv_strrpos() : error conditions ***\n";
$haystack = 'This is an English string. 0123456789.';
$needle = '123';
$offset = 5;
$encoding = 'unknown-encoding';
var_dump(iconv_strrpos($haystack, $needle, $encoding));
echo "Done";