Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php mb_ereg()无法正常工作_Php_Unicode_Arabic - Fatal编程技术网

php mb_ereg()无法正常工作

php mb_ereg()无法正常工作,php,unicode,arabic,Php,Unicode,Arabic,mb_ereg()工作不正常 $badword ="ناك"; // which mean F***. $TextToCheck = "في الكون هناك الكثير من الكواكب"; // In universe there's a lot of planets. mb_ereg("\b".$badword."\b", $TextToCheck, $text); echo $text[0]; // the output $text : ناك 这意味着单词(“هنا

mb_ereg()工作不正常

$badword ="ناك";  // which mean F***.

$TextToCheck = "في الكون هناك الكثير من الكواكب"; // In universe there's a lot of planets.

mb_ereg("\b".$badword."\b", $TextToCheck, $text);

echo $text[0]; // the output $text : ناك
这意味着单词(“هناك”=那里)被发现为“ناك”,这意味着mbهereg没有计算第一个字母“ه”(هك)


任何情况下都有类似的情况,有解决方案吗?

使用
preg\u match
而不是
mb\u ereg
函数

$badword ="ناك";  // which mean ****.

$TextToCheck = "في الكون هناك الكثير من الكواكب"; // In universe there's a lot of planets.

preg_match("/".$badword."/", $TextToCheck, $text);

echo $text[0];

我认为问题在于你的文件编码,这个函数对我来说很好,例如:你就是那个人,这不是关于编码,而是关于php版本,我有PHPV5.3.0,当我在服务器上将其更改为5.6时,它工作得很好。这是一个超过5个小时的测试/搜索,没有运气,所以非常感谢你,这是不对的,因为在这种情况下,输出应该是空的,因为没有单词=“ناك”,有一个不同的“هن㶋ك”。هنا㶋ك包含单词,不是吗