我想将数组转换为JSON。我的问题是,数组中的元素之一包含单引号,双引号等如何将数组转换为包含PHP中双引号的json?
<textarea name="description" id="description">
Tesla is the living definition of bad*** and mad scientist.
During Tesla's later years, he made claims concerning a
"teleforce" weapon after studying the Van de Graaff generator.
The press called it a "peace ray" or death ray. Tesla described
the weapon as being able to be used against ground-based infantry
or for antiaircraft purposes.
</textarea>
当我提交我:
$description = $_POST['description'];
json_encode($description);
当我对其进行解码,我只是其中的一部分字符串。
哪里是完整的代码? – Ghost 2014-09-23 03:05:06
addslashes()http://php.net/manual/en/function.addslashes.php将它包裹在你的$描述中应该解决这个问题。 – mschuett 2014-09-23 03:08:07
好的,当我使用addslashes()和retive从数据库中保存这个值时,会跳过apper? – user3054209 2014-09-23 03:11:03