[eluser]dottedquad[/eluser]
Hello all,
My current code:
Code:
function get_location_list()
{
$location_list = array();
$query = $this->db->query('SELECT id, location FROM location');
foreach ($query->result_array() as $row)
{
$value = $row['id'];
$text = $row['location'];
$location_list['result'][$value] = $text;
}
echo json_encode($location_list);
//return ;
}
My JSON is formatted as such:
{"result":{"1":"chickenpen 1","2":"chickenpen 2","3":"chickenpen 3","4":"chickenpen 4"}}
It should be formatted like:
Code:
{"results":[
{"id":1,"name":"chickenpen 1"},
{"id":2,"name":"chickenpen 2"},
{...} // more results here...
]}
How do I get my JSON string to be formatted like the above sample?
-Thank You,
Rich