我有以下 PHP 代码:
\n\n$search = "foo bar que";\n$search_string = str_replace(" ", "|", $search);\n\n$text = "This is my foo text with qu\xc3\xa9 and other accented characters.";\n$text = preg_replace("/$search_string/i", "<b>$0</b>", $text);\n\necho $text;\nRun Code Online (Sandbox Code Playgroud)\n\n显然,“que”与“qu\xc3\xa9”不匹配。我怎样才能改变这一点?有没有办法让preg_replace忽略所有口音?
必须匹配的字符(西班牙语):
\n\n\xc3\xa1,\xc3\x81,\xc3\xa9,\xc3\x89,\xc3\xad,\xc3\x8d,\xc3\xb3,\xc3\x93,\xc3\xba,\xc3\x9a,\xc3\xb1,\xc3\x91\nRun Code Online (Sandbox Code Playgroud)\n\n我不想在应用正则表达式之前替换所有重音字符,因为文本中的字符应该保持不变:
\n\n“这是我的foo文本,带有qu\xc3\xa9和其他重音字符。”
\n\n并不是
\n\n“这是我的foo文本,带有que和其他重音字符。”
\n我想在多维数组的最深/最后一级计算相同的值:
Array
(
[svote001] => Array
(
[0] => 006
[1] => 006
[2] => 007
)
[svote002] => Array
(
[0] => 000
[1] => 000
[2] => 000
)
[svote003] => Array
(
[0] => 002
[1] => 003
[2] => 001
)
)
Run Code Online (Sandbox Code Playgroud)
转换成
Array
(
[svote001] => Array
(
[006] => 2
[007] => 1
)
[svote002] => Array
(
[000] => 3
)
[svote003] => Array
(
[001] => 1
[002] => 1
[003] => …Run Code Online (Sandbox Code Playgroud)