gpt4 book ai didi

php - 如何从 php 中的字符串中去除 unicode 字符 (LEFT_TO_RIGHT_MARK)

转载 作者:可可西里 更新时间:2023-10-31 23:09:43 28 4
gpt4 key购买 nike

我试图在将字符串编码为 JSON 之前从字符串中删除 LEFT-TO-RIGHT-MARK (\u200e) 和 RIGHT-TO-LEFT-MARK (\u200f)。以下任何一项似乎都不起作用:

$s = mb_ereg_replace("\u200e", '', $s);
$s = preg_replace("#\u200e#u", '', $s);
$s = preg_replace("#\u200e#", '', $s);

感谢任何帮助!

最佳答案

纠结了几天,终于找到答案了!

$str = preg_replace('/(\x{200e}|\x{200f})/u', '', $str);

关于php - 如何从 php 中的字符串中去除 unicode 字符 (LEFT_TO_RIGHT_MARK),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1930009/

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