Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove quote on echo json_encode();

Tags:

json

ajax

php

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

Problem is I'm getting the result with double quotes, how to remove the double quotes

like image 449
Ree Avatar asked Nov 30 '25 14:11

Ree


1 Answers

Try trim in php

<?php 
$name = "Aman";
$str = json_encode($name);
echo trim($str, '"');  // output : Aman
?>
like image 68
Aman Kumar Avatar answered Dec 02 '25 02:12

Aman Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!