$result = mysql_query("SELECT * FROM $tableName WHERE id=1");
$array = mysql_fetch_array($result);
$help_name = $array['name'];
$req = $array['req'];
//fetch result
echo json_encode($help_name);
问题是我用双引号获取结果,如何删除双引号
答案 0 :(得分:5)
<?php
$name = "Aman";
$str = json_encode($name);
echo trim($str, '"'); // output : Aman
?>
答案 1 :(得分:1)
$help_name = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', $help_name);