1--TEST-- 2Test mb_strrchr() function : variation - multiple needles 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_strrchr') or die("skip mb_strrchr() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* Prototype : string mb_strrchr(string haystack, string needle[, bool part[, string encoding]]) 11 * Description: Finds the last occurrence of a character in a string within another 12 * Source code: ext/mbstring/mbstring.c 13 * Alias to functions: 14 */ 15 16echo "*** Testing mb_strrchr() : variation ***\n"; 17 18mb_internal_encoding('UTF-8'); 19 20//with repeated needles 21$string_ascii = b'abcdef zbcdyx'; 22$needle_ascii = b"bcd"; 23 24//Japanese string in UTF-8 with repeated needles 25$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OIMzTvvJXvvJbml6XmnKzoqp7jg4bjgq3jgrnjg4g='); 26$needle_mb = base64_decode('6Kqe44OG44Kt'); 27 28echo "-- Ascii data --\n"; 29var_dump(bin2hex(mb_strrchr($string_ascii, $needle_ascii, false))); 30var_dump(bin2hex(mb_strrchr($string_ascii, $needle_ascii, true))); 31 32echo "-- mb data in utf-8 --\n"; 33$res = mb_strrchr($string_mb, $needle_mb, false); 34if ($res !== false) { 35 var_dump(bin2hex($res)); 36} 37else { 38 echo "nothing found!\n"; 39} 40$res = mb_strrchr($string_mb, $needle_mb, true); 41if ($res !== false) { 42 var_dump(bin2hex($res)); 43} 44else { 45 echo "nothing found!\n"; 46} 47 48 49?> 50===DONE=== 51--EXPECT-- 52*** Testing mb_strrchr() : variation *** 53-- Ascii data -- 54string(10) "6263647978" 55string(16) "616263646566207a" 56-- mb data in utf-8 -- 57string(30) "e8aa9ee38386e382ade382b9e38388" 58string(70) "e697a5e69cace8aa9ee38386e382ade382b9e383883334efbc95efbc96e697a5e69cac" 59===DONE=== 60