PHP:将单引号字符串转换为双引号

时间:2016-05-25 18:13:57

标签: php unicode escaping double-quotes single-quotes

我需要将带有unicode \ xCODEs的字符串转换为常规字符串。 问题是我输入的字符串似乎是单引号。

有没有办法将单引号字符串转换为double?

以下是一些可以更好理解的代码:

$s1 = '(single quotes): Conductivity @ 20\xc3\x82\xc2\xb0C';
$s2 = "(double quotes): Conductivity @ 20\xc3\x82\xc2\xb0C";

echo "<br>";
echo iconv("UTF-8", "ISO-8859-1//IGNORE", $s1);
echo "<br>";
echo iconv("UTF-8", "ISO-8859-1//IGNORE", $s2);

将输出:

(single quotes): Conductivity @ 20\xc3\x82\xc2\xb0C
(double quotes): Conductivity @ 20°C

提前致谢!

1 个答案:

答案 0 :(得分:2)

转向我正在寻找stripcslashes

非常感谢@mario!