如何替换获取poster作为参数的字符串



当前我面临替换字符串的问题,我使用了poster&在邮递员中传递像[{"id":"115","flag":"1","qty":"3","size":"10"}]这样的字符串作为参数,但当我打印字符串时,我得到的输出像[{"id":"115","flag":"1","qty":"3","size":"10"}],所以我只想从字符串中删除'',我已经尝试了以下代码,但没有成功。

$fliesid_in_store = $_REQUEST['fliesid_in_store'];
echo $res = preg_replace("/[^a-zA-Z]/", "", $fliesid_in_store);

你试过条纹斜杠吗。

$fliesid_in_store = $_REQUEST['fliesid_in_store'];
echo stripslashes($fliesid_in_store);

您提到的字符串是json格式的

$json = [{"id":"115","flag":"1","qty":"3","size":"10"}] //this is json

将其分配给变量并解码。

$string = json_decode($json,TRUE) this give result in array format

在您的情况下

$string = json_decode($_REQUEST['fliesid_in_store'],TRUE);

最新更新