PHP client data list in JSON

2

Good afternoon guys,

Well I have a CRUD in PHP and I need to have the registered clients shown in another URL in JSON

But I've been a bit weak in PHP, I have no idea how to do this with data coming from a query in the DB, does anyone know how to do it?

    
asked by anonymous 04.10.2015 / 01:22

1 answer

1

Assuming that the data that you brought from the DB is in an array or object called $data , you just have to use the json_encode function, the code would look like this:

// código para obter os dados do BD
echo json_encode($data);

More details about the json_encode function here: link

    
04.10.2015 / 01:59