PHP: Convert single-quoted string into double-quoted

≡放荡痞女 提交于 2019-12-23 18:41:38

问题


I need to convert string with unicode \xCODEs into regular string. The issue is that string which I have as input seems to be single-quoted.

Is there any way to convert single-quoted string into double?

Here's some code for better understanding:

$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);

will output:

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

Thanks in advance!


回答1:


It turns that I was looking for stripcslashes

Many thanks @mario!



来源:https://stackoverflow.com/questions/37444753/php-convert-single-quoted-string-into-double-quoted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!