在PHP中替换双引号和反斜杠\”

h5qlskok  于 2022-11-21  发布在  PHP
关注(0)|答案(1)|浏览(138)

如何正确地替换\“或从字符串中删除这些字符?它们必须放在一起,而不是分开

$string = '{"ID":"89t9ZUIx1Mt","Title":"Pen","Attribution":"\"Pen\" by Jarlan Perez, https://poly.pizza/m/89t9ZUIx1Mt. Licence at https://creativecommons.org/licenses/by/3.0"';
$replaced = str_replace("\"\\", "",$string);
echo $replaced;

结果:{"ID":"89t9ZUIx1Mt","Title":"Pen","Attribution":"Pen\" by Jarlan Perez, https://poly.pizza/m/89t9ZUIx1Mt. Licence at https://creativecommons.org/licenses/by/3.0"
目标:

{"ID":"89t9ZUIx1Mt","Title":"Pen","Attribution":"Pen by Jarlan Perez, https://poly.pizza/m/89t9ZUIx1Mt. Licence at https://creativecommons.org/licenses/by/3.0"
bvhaajcl

bvhaajcl1#

$replaced = str_replace('\\"', '',$string);

最终解决方案

相关问题