本文整理汇总了PHP中mb_strrichr函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_strrichr函数的具体用法?PHP mb_strrichr怎么用?PHP mb_strrichr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_strrichr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
function find($needle, $ignoreCase = false, $reverse = false)
{
if ($ignoreCase) {
if ($reverse) {
$this->__invar = mb_strrichr($this->__invar, $needle);
} else {
$this->__invar = mb_stristr($this->__invar, $needle);
}
} else {
if ($reverse) {
$this->__invar = mb_strrchr($this->__invar, $needle);
} else {
$this->__invar = mb_strstr($this->__invar, $needle);
}
}
return $this;
}
示例2: testUsingMbStrrichr
/**
* testUsingMbStrrichr method
*
* @return void
*/
public function testUsingMbStrrichr()
{
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$find = 'F';
$result = mb_strrichr($string, $find);
$expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789';
$this->assertEquals($expected, $result);
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$find = 'F';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ABCDE';
$this->assertEquals($expected, $result);
$string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ';
$find = 'Å';
$result = mb_strrichr($string, $find);
$expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ';
$this->assertEquals($expected, $result);
$string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ';
$find = 'Å';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ÀÁÂÃÄ';
$this->assertEquals($expected, $result);
$string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
$find = 'Ċ';
$result = mb_strrichr($string, $find);
$expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
$this->assertEquals($expected, $result);
$string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
$find = 'Ċ';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ĀĂĄĆĈ';
$this->assertEquals($expected, $result);
$string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$find = 'F';
$result = mb_strrichr($string, $find);
$expected = 'fghijklmnopqrstuvwxyz{|}~';
$this->assertEquals($expected, $result);
$string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$find = 'F';
$result = mb_strrichr($string, $find, TRUE);
$expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcde';
$this->assertEquals($expected, $result);
$string = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ';
$find = 'µ';
$result = mb_strrichr($string, $find);
$expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ';
$this->assertEquals($expected, $result);
$string = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ';
$find = 'µ';
$result = mb_strrichr($string, $find, TRUE);
$expected = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´';
$this->assertEquals($expected, $result);
$string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ';
$find = 'Þ';
$result = mb_strrichr($string, $find);
$expected = 'þÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ';
$this->assertEquals($expected, $result);
$string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ';
$find = 'Þ';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüý';
$this->assertEquals($expected, $result);
$string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ';
$find = 'Ņ';
$result = mb_strrichr($string, $find);
$expected = 'ņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ';
$this->assertEquals($expected, $result);
$string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ';
$find = 'Ņ';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅ';
$this->assertEquals($expected, $result);
$string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ';
$find = 'Ƹ';
$result = mb_strrichr($string, $find);
$expected = 'ƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ';
$this->assertEquals($expected, $result);
$find = 'Ƹ';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸ';
$this->assertEquals($expected, $result);
$string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ';
$find = 'ʀ';
$result = mb_strrichr($string, $find);
$expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ';
$this->assertEquals($expected, $result);
$string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ';
$find = 'ʀ';
$result = mb_strrichr($string, $find, TRUE);
$expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ';
$this->assertEquals($expected, $result);
$string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ';
$find = 'Ї';
$result = mb_strrichr($string, $find);
$expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ';
//.........这里部分代码省略.........
示例3: fopen
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for part
foreach ($inputs as $key => $value) {
echo "\n--{$key}--\n";
$res = mb_strrichr($haystack, $needle, $value, $encoding);
if ($res === NULL) {
var_dump($res);
} else {
var_dump(bin2hex($res));
}
}
fclose($fp);
?>
===DONE===
示例4: mb_strrichr
<?php
/* Prototype : string mb_strrichr(string haystack, string needle[, bool part[, string encoding]])
* Description: Finds the last occurrence of a character in a string within another, case insensitive
* Source code: ext/mbstring/mbstring.c
* Alias to functions:
*/
echo "*** Testing mb_strrichr() : error conditions ***\n";
//Test mb_strrichr with one more than the expected number of arguments
echo "\n-- Testing mb_strrichr() function with more than expected no. of arguments --\n";
$haystack = 'string_val';
$needle = 'string_val';
$part = true;
$encoding = 'string_val';
$extra_arg = 10;
var_dump(mb_strrichr($haystack, $needle, $part, $encoding, $extra_arg));
// Testing mb_strrichr with one less than the expected number of arguments
echo "\n-- Testing mb_strrichr() function with less than expected no. of arguments --\n";
$haystack = 'string_val';
var_dump(mb_strrichr($haystack));
?>
===DONE===
示例5: __toString
// define some classes
class classWithToString
{
public function __toString()
{
return "invalid";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
invalid
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for encoding
foreach ($inputs as $key => $value) {
echo "\n--{$key}--\n";
var_dump(mb_strrichr($haystack, $needle, $part, $value));
}
fclose($fp);
?>
===DONE===
示例6: strrichr
static function strrichr($s, $needle, $before_needle = false)
{
return mb_strrichr($s, $needle, $before_needle, 'UTF-8');
}
示例7: __toString
// define some classes
class classWithToString
{
public function __toString()
{
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for haystack
foreach ($inputs as $key => $value) {
echo "\n--{$key}--\n";
var_dump(mb_strrichr($value, $needle, $part, $encoding));
}
fclose($fp);
?>
===DONE===
示例8: rStr
/**
* Find last occurrence of a string in this string
* @param string $needle
* @param bool $caseInsensitive
* @param bool $beforeNeedle If true, return first part of string excluding needle.
* If false, return needle + last part of string
* @return string
*/
public function rStr($needle, $caseInsensitive = false, $beforeNeedle = false)
{
if ($caseInsensitive) {
return mb_strrichr($this->string, $needle, $beforeNeedle, $this->encoding);
}
return mb_strrchr($this->string, $needle, $beforeNeedle, $this->encoding);
}
示例9: var_dump
var_dump(mb_stripos("abcdefÜ" . "abcdef", "A", 1, "UTF-8"));
var_dump(mb_stristr("Hello World!", "earth"));
var_dump(mb_strlen("test"));
var_dump(mb_strlen("PrÜÝ" . "fung"));
var_dump(mb_strpos("abcdef abcdef", "a", 1));
var_dump(mb_strpos("abcdefÜ" . "abcdef", "a", 1));
var_dump(mb_strpos("abcdefÜ" . "abcdef", "A", 1));
$text = "Line 1\nLine 2\nLine 3";
var_dump(mb_strrchr($text, "\n"));
$text = "Line 1\nLine 2Ü" . "Line 3";
var_dump(strrchr($text, "�") === "�" . "Line 3");
// mb_strrchr behaves differently in different versions of
// libmbfl (https://github.com/facebook/hiphop-php/issues/68)
var_dump(mb_strrchr($text, "�") === false || mb_strrchr($text, "�") === "Line 3");
$text = "Line 1\nLine 2\nLine 3";
var_dump(mb_strrichr($text, "l"));
var_dump(mb_strripos("abcdef abcdef", "A"));
var_dump(mb_strripos("abcdefÜ" . "abcdef", "A"));
var_dump(mb_strrpos("abcdef abcdef", "a"));
var_dump(mb_strrpos("abcdefÜ" . "abcdef", "a"));
$email = "name@example.com";
var_dump(mb_strstr($email, "@"));
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = mb_strtolower($str);
var_dump($str);
var_dump(mb_strtolower("ABC"));
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = mb_strtoupper($str);
var_dump($str);
var_dump(mb_strtoupper("abc"));
var_dump(mb_strwidth("PrÜ" . "fung"));
示例10: __toString
// define some classes
class classWithToString
{
public function __toString()
{
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -2345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float 12.3456789000e10' => 123456789000.0, 'float -12.3456789000e10' => -123456789000.0, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $fp);
// loop through each element of the array for needle
foreach ($inputs as $key => $value) {
echo "\n--{$key}--\n";
var_dump(mb_strrichr($haystack, $value, $part, $encoding));
}
fclose($fp);
?>
===DONE===
示例11: mb_strrichr
* Description: Finds the last occurrence of a character in a string within another, case insensitive
* Source code: ext/mbstring/mbstring.c
* Alias to functions:
*/
echo "*** Testing mb_strrichr() : basic functionality ***\n";
mb_internal_encoding('UTF-8');
$string_ascii = 'abcdef';
$needle_ascii_upper = "BCD";
$needle_ascii_mixed = "bCd";
$needle_ascii_lower = "bcd";
//Greek string in lower case UTF-8
$string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
$needle_mb_upper = base64_decode('zpzOnc6ezp8=');
$needle_mb_lower = base64_decode('zrzOvc6+zr8=');
$needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
echo "\n-- ASCII string: needle exists --\n";
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false, 'ISO-8859-1')));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
echo "\n-- ASCII string: needle doesn't exist --\n";
var_dump(mb_strrichr($string_ascii, '123'));
echo "\n-- Multibyte string: needle exists --\n";
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false, 'utf-8')));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
echo "\n-- Multibyte string: needle doesn't exist --\n";
$needle2 = base64_decode('zrzOvs6/');
var_dump(mb_strrichr($string_mb, $needle2));
?>
===DONE===
示例12: mb_strpos
<?php
echo mb_strpos('abb', 'b', null, 'UTF-8') . "\n";
echo mb_strrpos('abb', 'b', null, 'UTF-8') . "\n";
echo mb_stripos('abb', 'B', null, 'UTF-8') . "\n";
echo mb_strripos('abb', 'B', null, 'UTF-8') . "\n";
echo mb_strstr('foobarbaz', 'ba', null, 'UTF-8') . "\n";
echo mb_strrchr('foobarbaz', 'ba', null, 'UTF-8') . "\n";
echo mb_stristr('foobarbaz', 'BA', null, 'UTF-8') . "\n";
echo mb_strrichr('foobarbaz', 'BA', null, 'UTF-8') . "\n";
echo mb_substr('foobarbaz', 6, null, 'UTF-8') . "\n";
echo mb_strcut('foobarbaz', 6, null, 'UTF-8') . "\n";
echo mb_strimwidth('foobar', 0, 3, null, 'UTF-8') . "\n";
?>
==DONE==
示例13: mb_strrichr
* Alias to functions:
*/
echo "*** Testing mb_strrichr() : basic functionality ***\n";
mb_internal_encoding('UTF-8');
//ascii mixed case, multiple needles
$string_ascii = 'abcDef zBcDyx';
$needle_ascii_upper = "BCD";
$needle_ascii_mixed = "bCd";
$needle_ascii_lower = "bcd";
//Greek string in mixed case UTF-8 with multiple needles
$string_mb = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
$needle_mb_upper = base64_decode('zpzOnc6ezp8=');
$needle_mb_lower = base64_decode('zrzOvc6+zr8=');
$needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
echo "\n-- ASCII string: needle exists --\n";
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, true)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, false)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, true)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, false)));
var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
echo "\n-- Multibyte string: needle exists --\n";
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, false)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, true)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, true)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, false)));
var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
?>
===DONE===
示例14: iLastOccurrence
/**
* Busca a última ocorrência de uma string (Case Insensitive)
* @param string $str A string a ser localizada
* @param boolean $before_char Define qual parte da string será retornada<br>
* Caso seja <b>TRUE</b> retornará toda a string até o início da última
* ocorrência de $char <br>
* Caso seja <b>FALSE</b> retornará toda a string a partir da última
* ocorrência de $char
* @return TString|boolean Retorna um objeto String contendo o conteúdo de acordo com
* o parâmetro $before_char ou <b>false</b> caso não seja encontrada nenhuma ocorrência
*/
public function iLastOccurrence($str, $before_char = false)
{
$r = mb_strrichr($this->getValue(), $str, $before_char, $this->getEncoding());
if ($r) {
return new TString($r);
} else {
return false;
}
}
示例15: mb_strrichr
<?php
/* Prototype : string mb_strrichr(string haystack, string needle[, bool part[, string encoding]])
* Description: Finds the last occurrence of a character in a string within another, case insensitive
* Source code: ext/mbstring/mbstring.c
* Alias to functions:
*/
echo "*** Testing mb_strrichr() : error conditions ***\n";
echo "\n-- Testing mb_strrichr() with unknown encoding --\n";
$haystack = 'Hello, world';
$needle = 'world';
$encoding = 'unknown-encoding';
$part = true;
var_dump(mb_strrichr($haystack, $needle, $part, $encoding));
?>
===DONE===