Connor Bishop Connor Bishop - 1 year ago 70
JSON Question

Echoing JSON Data in php

Im trying to echo some JSON Data. The problem is the data contains variables but my code isn't putting the variables into the string.
Heres my code:

$status = $row['Status'];
$priority = $row['Priority'];
echo '{"status":"$status","priority":"$priority"}' ;

this php is echoing


when I need to echo


for example. How can I fix this?

Answer Source

Just use json_encode function

echo json_encode($row);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download