echo json_encode($row) returns duplicate values

here’s my php code

$result = mysql_query("select * from backup where owner='$email'") or die (mysql_error());
$dataCount = mysql_num_rows($result);
$row = mysql_fetch_array($result);
echo json_encode($row);

and it returns this:


this is how shows it

fyi, there’s only one row of data inside the table. but it seems json_encode($row) displays the value twice, but firstly using number (0 – 4) as the label, then it uses the column name (id, year, necessities, savings, entertainment) as the label.

how can I make it to display the value only once, using the column name?

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.