I have a question about formating a json in php. Here is my code
public function testing() {
if (!empty($_POST)) {
$this->db->select('*');
$this->db->from('trash_table');
$this->db->where('Description',$_POST['Descp']);
$q = $this->db->get();
if($q->num_rows() > 0 )
//here should be something better
print json_encode($q->result());
}
With my current simple php code, I'm just getting everything as a JSONArray.
[
{"ID":1,"Description":"hello",
{"ID":2,"Description":"hellou"}
]
But I want to format it on my own way, something like this...Hope you guys help. Thank you in advanced!
{
"Answer": {
"Success": "Yup"
},
"List": [
{"ID":1,
"Description":"hello"},
{"ID":2,
"Description":"hellou"}]
}