本文整理汇总了PHP中mb_strripos函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_strripos函数的具体用法?PHP mb_strripos怎么用?PHP mb_strripos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_strripos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testmb_strpos
/**
* @covers Patchwork\PHP\Override\Mbstring::mb_strpos
* @covers Patchwork\PHP\Override\Mbstring::mb_stripos
* @covers Patchwork\PHP\Override\Mbstring::mb_strrpos
* @covers Patchwork\PHP\Override\Mbstring::mb_strripos
*/
function testmb_strpos()
{
$this->assertSame(false, @mb_strpos('abc', ''));
$this->assertSame(false, @mb_strpos('abc', 'a', -1));
$this->assertSame(false, mb_strpos('abc', 'd'));
$this->assertSame(false, mb_strpos('abc', 'a', 3));
$this->assertSame(1, mb_strpos('한국어', '국'));
$this->assertSame(3, mb_stripos('DÉJÀ', 'à'));
$this->assertSame(false, mb_strrpos('한국어', ''));
$this->assertSame(1, mb_strrpos('한국어', '국'));
$this->assertSame(3, mb_strripos('DÉJÀ', 'à'));
$this->assertSame(1, mb_stripos('aςσb', 'ΣΣ'));
$this->assertSame(1, mb_strripos('aςσb', 'ΣΣ'));
$this->assertSame(false, @p::mb_strpos('abc', ''));
$this->assertSame(false, @p::mb_strpos('abc', 'a', -1));
$this->assertSame(false, p::mb_strpos('abc', 'd'));
$this->assertSame(false, p::mb_strpos('abc', 'a', 3));
$this->assertSame(1, p::mb_strpos('한국어', '국'));
$this->assertSame(3, p::mb_stripos('DÉJÀ', 'à'));
$this->assertSame(false, p::mb_strrpos('한국어', ''));
$this->assertSame(1, p::mb_strrpos('한국어', '국'));
$this->assertSame(3, p::mb_strripos('DÉJÀ', 'à'));
$this->assertSame(1, p::mb_stripos('aςσb', 'ΣΣ'));
$this->assertSame(1, p::mb_strripos('aςσb', 'ΣΣ'));
}
示例2: validateEquals
protected function validateEquals($input)
{
if (is_array($input)) {
return end($input) == $this->endValue;
}
return mb_strripos($input, $this->endValue, -1, $enc = mb_detect_encoding($input)) === mb_strlen($input, $enc) - mb_strlen($this->endValue, $enc);
}
示例3: execute
/**
* LastIndexOf
*/
public function execute()
{
if ($this->isCaseInsensitive()) {
return mb_strripos($this->getValue(), $this->needle, $this->fromIndex);
} else {
return mb_strrpos($this->getValue(), $this->needle, $this->fromIndex);
}
}
示例4: formatShortString
public function formatShortString($string, $maxlen = 200, $separator = '...')
{
$string = preg_replace('#<(?:br|p|hr|div)#', ' $0', $string);
$string = strip_tags($string);
$len = mb_strlen($string, 'UTF-8') > $maxlen ? mb_strripos(mb_substr($string, 0, $maxlen, 'UTF-8'), ' ', 0, 'UTF-8') : $maxlen;
$cutStr = mb_substr($string, 0, $len, 'UTF-8');
return mb_strlen($string, 'UTF-8') > $maxlen ? '' . $cutStr . $separator : '' . $cutStr . '';
}
示例5: cutString
function cutString($string, $maxlen)
{
//обрезает красиво строку, убирает теги, добавляя ... в конце
$string = strip_tags($string);
$len = mb_strlen($string) > $maxlen ? mb_strripos(mb_substr($string, 0, $maxlen), ' ') : $maxlen;
$cutStr = mb_substr($string, 0, $len);
return mb_strlen($string) > $maxlen ? $cutStr . '...' : $cutStr;
}
示例6: utf8_strripos
public static function utf8_strripos($haystack, $needle, $offset)
{
if (UTF8_MBSTRING) {
self::_fixMbStrrposPhp52($haystack, $offset);
return mb_strripos($haystack, $needle, $offset);
} else {
return strripos($haystack, $needle, $offset);
}
}
示例7: injectEditor
/**
* @param Response $response
* @param string $editorHtml
*/
private function injectEditor(Response $response, $editorHtml)
{
$html = $response->getContent();
$pos = mb_strripos($html, '</body>');
if (false === $pos) {
return;
}
$html = mb_substr($html, 0, $pos) . $editorHtml . mb_substr($html, $pos);
$response->setContent($html);
}
示例8: injectCookieBar
protected function injectCookieBar(Response $response)
{
$content = $response->getContent();
$pos = mb_strripos($content, '</body>');
if (false !== $pos) {
$toolbar = sprintf("\n%s\n", $this->cookieService->render());
$content = mb_substr($content, 0, $pos) . $toolbar . mb_substr($content, $pos);
$response->setContent($content);
}
}
示例9: fixEmbeddedAttachments
protected function fixEmbeddedAttachments($message, $oldID, $newID)
{
if (mb_strripos($message, '[attach]' . $oldID . '[/attach]') !== false || mb_strripos($message, '[attach=' . $oldID . ']') !== false || mb_strripos($message, '[attach=' . $oldID . ',') !== false) {
$message = str_ireplace('[attach]' . $oldID . '[/attach]', '[attach]' . $newID . '[/attach]', $message);
$message = str_ireplace('[attach=' . $oldID . ']', '[attach=' . $newID . ']', $message);
$message = str_ireplace('[attach=' . $oldID . ',', '[attach=' . $newID . ',', $message);
return $message;
}
return false;
}
示例10: get_words
/**
* Генерация слов по которым найдена акция
* @param $news
* @return $this
*/
public function get_words($news)
{
$words = array();
foreach ($this->_original_words as $word) {
if (mb_strripos($news->title, $word) !== FALSE or mb_strripos($news->text, $word) !== FALSE) {
$words[] = $word;
}
}
$words = array_unique($words);
return View::factory('frontend/search/search_words')->set('words', $words);
}
示例11: mb_trim_word
/**
* Обрезание текста по длине с поиском последнего полностью вмещающегося слова и удалением лишних крайних знаков пунктуации.
*
* @author Agel_Nash <Agel_Nash@xaker.ru>
* @version 0.1
*
* @param string $html HTML текст
* @param integer $len максимальная длина строки
* @param string $encoding кодировка
* @return string
*/
public static function mb_trim_word($html, $len, $encoding = 'UTF-8')
{
$text = trim(preg_replace('|\\s+|', ' ', strip_tags($html)));
$text = mb_substr($text, 0, $len + 1, $encoding);
if (mb_substr($text, -1, null, $encoding) == ' ') {
$out = trim($text);
} else {
$out = mb_substr($text, 0, mb_strripos($text, ' ', null, $encoding), $encoding);
}
return preg_replace("/(([\\.,\\-:!?;\\s])|(&\\w+;))+\$/ui", "", $out);
}
示例12: injectToolbar
/**
* @param \Symfony\Component\HttpFoundation\Response $response
*/
protected function injectToolbar(Response $response)
{
$content = $response->getContent();
$pos = mb_strripos($content, '</body>');
if (FALSE !== $pos) {
if ($token = $response->headers->get('X-Debug-Token')) {
$loader = ['#theme' => 'webprofiler_loader', '#token' => $token, '#profiler_url' => $this->urlGenerator->generate('webprofiler.toolbar', ['profile' => $token])];
$content = mb_substr($content, 0, $pos) . $this->renderer->renderRoot($loader) . mb_substr($content, $pos);
$response->setContent($content);
}
}
}
示例13: xyz_fbap_string_limit
function xyz_fbap_string_limit($string, $limit)
{
$space = " ";
$appendstr = " ...";
if (mb_strlen($string) <= $limit) {
return $string;
}
if (mb_strlen($appendstr) >= $limit) {
return '';
}
$string = mb_substr($string, 0, $limit - mb_strlen($appendstr));
$rpos = mb_strripos($string, $space);
if ($rpos === false) {
return $string . $appendstr;
} else {
return mb_substr($string, 0, $rpos) . $appendstr;
}
}
示例14: softCut
/**
* Soft cutting for string
*
* @param string $string Source string
* @param integer $soft Soft cutting position
* @param integer $hard Hard cutting position
* @param integer $strategy Cutting strategy [optional]
* @param boolean $strip Strip tags in source [optional]
* @param string $encoding Source encoding [optional]
* @return string Cutted string
*/
public static function softCut($string, $soft, $hard, $strategy = self::CUT_STRATEGY_MIN, $strip = true, $encoding = 'utf-8')
{
if ($strip) {
$string = strip_tags($string);
}
if (mb_strlen($string) <= $soft) {
return $string;
}
$cut = mb_substr($string, 0, $hard, $encoding);
$pos = $strategy == self::CUT_STRATEGY_MIN ? mb_stripos($cut, ' ', $soft, $encoding) : mb_strripos($cut, ' ', $soft, $encoding);
if ($pos === false) {
$pos = $strategy == self::CUT_STRATEGY_MIN ? mb_stripos($cut, ' ', $soft, $encoding) : mb_strripos($cut, ' ', $soft, $encoding);
}
if ($pos === false) {
$pos = $strategy == self::CUT_STRATEGY_MIN ? mb_stripos($cut, ' ', $soft, $encoding) : mb_strripos($cut, ' ', $soft, $encoding);
}
if ($pos === false) {
return $cut;
}
return mb_substr($string, 0, $pos, $encoding);
}
示例15: 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) {
$offset = 0;
}
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;
}