我如何用PHP中的引号回显行

does anyone of you know how i can echo this " echo $row['time']; " in quotation marks.

The print should look like "XYZ"

I need this for my own JSON style which will be used in an app..

Thanks in advance :)

You can concate "" using in echo as

 echo '"'.$row['time'].'"';

You can also escape " within a "-delimited string:

echo "\"$row['time']\"";

Thnx for the heads-up on the extra ;. Now, what is the syntax error? Is it the ' around time, or something else? It's very possible that some PHPs will not like trying to interpolate an array element inside a string, and you'll have to go to concatenation.

Try this

print json_encode($row['time']);

You Probably want this:

$result = mysql_query("SELECT * FROM table");
if($result){
$rows = array();
$count = mysql_num_rows($result); 
if($count > 0){
  $i = 0;
  while ($r = mysql_fetch_assoc($result)) {
$rows[$i]['time'] = $r['time'];
$i++;
  }
echo json_encode(array('data' => $rows)); 
}

Above code will give you something like,

{
"data": [
    {
       "time": "first row time"
    },
    {
       "time": "second row time"
    }
   ]
  }