I\'m trying to get an array of objects with data from my database into jquery to render on a website.
ex: example.php
function testFunction() {
$data = array();
$mydata = new stdClass;
$mydata->example = 'test';
$data[] = (array) $mydata;
return json_encode($data);
}
echo testFunction();
The response is:
[{"example":"test"}]
The key here is (array) $mydata which converts the stdclass to an array before putting it in $data