删除echo上的引用json_encode();

时间:2017-02-28 12:48:18

标签: php json ajax

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

问题是我用双引号获取结果,如何删除双引号

2 个答案:

答案 0 :(得分:5)

在php中尝试修剪

<?php 
$name = "Aman";
$str = json_encode($name);
echo trim($str, '"');  // output : Aman
?>

答案 1 :(得分:1)

$help_name = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', $help_name);