1--TEST-- 2Test mb_substr_count() function : variation - pass a $needle that overlaps in $haystack 3--EXTENSIONS-- 4mbstring 5--FILE-- 6<?php 7/* 8 * Pass mb_substr_count() a $needle that overlaps in $haystack and see whether 9 * it counts only the first occurrence or all other occurrences regardless whether they 10 * were part of previous match 11 */ 12 13echo "*** Testing mb_substr_count() : usage variations ***\n"; 14 15 16echo "\n-- ASCII String --\n"; 17$string_ascii = 'abcabcabc'; 18var_dump(mb_substr_count($string_ascii, 'abcabc')); //needle overlaps in haystack 19 20echo "\n-- Multibyte String --\n"; 21$string_mb = base64_decode('5pel5pys6Kqe5pel5pys6Kqe5pel5pys6Kqe'); 22$needle_mb = base64_decode('5pel5pys6Kqe5pel5pys6Kqe'); 23var_dump(mb_substr_count($string_mb, $needle_mb, 'utf-8')); 24 25 26echo "Done"; 27?> 28--EXPECT-- 29*** Testing mb_substr_count() : usage variations *** 30 31-- ASCII String -- 32int(1) 33 34-- Multibyte String -- 35int(1) 36Done 37