ajax calls below php and expect an array of json to be return. I think I have the data ready but don't know how to return them correctly.
$files = array();
foreach($db2_databaselist as $db) {
$file = new stdClass();
$file->data = date('Y-m-d--H:i:s',strtotime($db));
$file->attr = new stdClass();
$file->attr->rel = "file";
$file->attr->timestamp = $db.$type[0];
$files[] = json_encode($file);
}
echo "<pre>Output = " . print_r($files,TRUE) . "</pre>";
echo "<BR><BR><BR>";
print_r($files, TRUE);
where print_r($files,TRUE) gives me
Output = Array
(
[0] => {"data":"2011-08-07--02:30:05","attr":{"rel":"file","timestamp":"20110807023005w"}}
[1] => {"data":"2011-07-31--02:30:09","attr":{"rel":"file","timestamp":"20110731023009w"}}
[2] => {"data":"2011-07-24--02:30:09","attr":{"rel":"file","timestamp":"20110724023009w"}}
)
But print_r($files,TRUE) returns nothing.
How can I get php to return
[
{"data":"2011-08-07--02:30:05","attr":{"rel":"file","timestamp":"20110807023005w"}},
{"data":"2011-07-31--02:30:09","attr":{"rel":"file","timestamp":"20110731023009w"}},
[2] => {"data":"2011-07-24--02:30:09","attr":{"rel":"file","timestamp":"20110724023009w"}}
]