私はいくつかのコードを書いているので、文字列内のいくつかの種類の記号を検索する必要があります。これにはmb_strpos関数を使用しますが、アルファベット記号では機能しますが、疑問符やドットなどの記号を検索すると機能しません。たとえば、文字列mb_strposで「aaaaa」(またはその他のUnicode文字)を検索した場合期待どおりに動作しますが、「?????」を検索すると そうではありません!
これは私のコードです:
function symbols_in_row($string, $limit=5) {
//split string by characters and generate new array containing each character
$symbol = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);
//remove duplicate symbols from array
$unique = array_unique($symbol);
//generate combination of symbols and search for them in string
for($x=0; $x<=count($unique); $x++) {
//generate combination of symbols
for($c=1; $c<=$limit; $c++) {
$combination .= $unique[$x];
}
//search for this combination of symbols in given string
$pos = mb_strpos($string, $combination);
if ($pos !== false) return false;
}
return true;
}
2番目のケースでは常にtrueを返します。
誰か助けてもらえますか?