$data = array();
$db = pc_base::load_model('content_model');
$sql="select a.id,a.title,a.url,a.status,a.catid,a.thumb,b.id,b.content from v9_news a,v9_news_data b where a.id=b.id and a.catid=7";
$k=$db->query($sql);
while($r = mysql_fetch_array($k)){
$data[]= (object)array('image'=>$r[thumb], 'title'=>$r[title]);
}
// 随机抽取9条记录以模拟实际情况
$keys = array_rand($data, 10);
$json = array();
foreach($keys as $key)
{
$json[] = $data[$key];
}
echo json_encode( $json );
print_r($data);
看看有些什么
json_encode 只能处理 utf-8 编码的数据