1--TEST--
2Test mb_strstr() function : variation - multiple needles
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strstr') or die("skip mb_strstr() is not available in this build");
7?>
8--FILE--
9<?php
10echo "*** Testing mb_strstr() : variation ***\n";
11
12mb_internal_encoding('UTF-8');
13
14//with repeated needles
15$string_ascii = 'abcdef zbcdyx';
16$needle_ascii = "bcd";
17
18//Japanese string in UTF-8 with repeated needles
19$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OIMzTvvJXvvJbml6XmnKzoqp7jg4bjgq3jgrnjg4g=');
20$needle_mb = base64_decode('6Kqe44OG44Kt');
21
22echo "-- Ascii data --\n";
23var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii, false)));
24var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii, true)));
25
26echo "-- mb data in utf-8 --\n";
27$res = mb_strstr($string_mb, $needle_mb, false);
28if ($res !== false) {
29    var_dump(bin2hex($res));
30}
31else {
32   echo "nothing found!\n";
33}
34$res = mb_strstr($string_mb, $needle_mb, true);
35if ($res !== false) {
36    var_dump(bin2hex($res));
37}
38else {
39   echo "nothing found!\n";
40}
41
42
43?>
44--EXPECT--
45*** Testing mb_strstr() : variation ***
46-- Ascii data --
47string(24) "6263646566207a6263647978"
48string(2) "61"
49-- mb data in utf-8 --
50string(88) "e8aa9ee38386e382ade382b9e383883334efbc95efbc96e697a5e69cace8aa9ee38386e382ade382b9e38388"
51string(12) "e697a5e69cac"
52