1--TEST--
2Test mb_strrichr() function : usage variation - multiple needles
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strrichr') or die("skip mb_strrichr() is not available in this build");
7?>
8--FILE--
9<?php
10/* Prototype  : string mb_strrichr(string haystack, string needle[, bool part[, string encoding]])
11 * Description: Finds the last occurrence of a character in a string within another, case insensitive
12 * Source code: ext/mbstring/mbstring.c
13 * Alias to functions:
14 */
15
16echo "*** Testing mb_strrichr() : basic functionality ***\n";
17
18mb_internal_encoding('UTF-8');
19
20//ascii mixed case, multiple needles
21$string_ascii = 'abcDef zBcDyx';
22$needle_ascii_upper = "BCD";
23$needle_ascii_mixed = "bCd";
24$needle_ascii_lower = "bcd";
25
26//Greek string in mixed case UTF-8 with multiple needles
27$string_mb = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
28$needle_mb_upper = base64_decode('zpzOnc6ezp8=');
29$needle_mb_lower = base64_decode('zrzOvc6+zr8=');
30$needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
31
32echo "\n-- ASCII string: needle exists --\n";
33var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false)));
34var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, true)));
35var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, false)));
36var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, true)));
37var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, false)));
38var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
39
40
41echo "\n-- Multibyte string: needle exists --\n";
42var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, false)));
43var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, true)));
44var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false)));
45var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, true)));
46var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, false)));
47var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
48
49?>
50===DONE===
51--EXPECT--
52*** Testing mb_strrichr() : basic functionality ***
53
54-- ASCII string: needle exists --
55string(10) "4263447978"
56string(16) "616263446566207a"
57string(10) "4263447978"
58string(16) "616263446566207a"
59string(10) "4263447978"
60string(16) "616263446566207a"
61
62-- Multibyte string: needle exists --
63string(20) "ce9cce9dcebecebfcea0"
64string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
65string(20) "ce9cce9dcebecebfcea0"
66string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
67string(20) "ce9cce9dcebecebfcea0"
68string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
69===DONE===
70