gpt4 book ai didi

php - 字符串中的某些字符不能被替换

转载 作者:行者123 更新时间:2023-12-02 05:36:19 25 4
gpt4 key购买 nike

我正在尝试更改此字符串

测试 - GGA ökologie Geschäftsführer.PDF

进入这个:

test_-_gga_oekologie_geschaaeftsfuuehrer.pdf

这是我试过的:

$characters = array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', ' ');
$converted_characters = array('ae', 'oe', 'ue', 'AE', 'OE', 'UE', '_');
$string = 'Test - GGA ökologie Geschäftsführer.PDF';

echo strtolower(str_replace($characters, $converted_characters , $string));

上面的代码返回:test_-_gga_ökologie_geschäftsführer.pdf

如您所见,字符串仍然包含字符 öä

我的代码有什么问题?

最佳答案

它们不是同一个 unicode 字符。如果您从字符串中复制并粘贴 ö 字符并将其粘贴到数组中,它将按预期工作。

关于php - 字符串中的某些字符不能被替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42951430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com