thinkphp多维数组合并数据,重组数组
$tieba_list= Db::name("tieba")->alias("a")
->join("tieba_pics p", "a.id=p.tid", 'LEFT')
->join("admin_upload b", "p.cover=b.id", "LEFT")
->join("member m", "a.user_id=m.id", "LEFT")
->join("tieba_list c","a.cate_id=c.id","LEFT")
->field("a.id,c.cate_name,a.title,m.username,b.ate_time")
->order("a.id desc")
->limit(6)
->select();
thinkphp多表查询输出:
数据重组:
$newArray = array();
foreach ($tieba_list as $row) {
$key = $row['id'];
if (array_key_exists($key, $tmpArray)) {
if (is_array($tmpArray[$key]['url'])) {
$tmpArray[$key]['url'][] = $row['url'];
} else {
$tmpArray[$key]['url'] = array($tmpArray[$key]['url'], $row['url']);
}thinkphp3
} else {
$tmpArray[$key] = $row;
}
}
重组后输出:
⾃⼰学习过程中的笔记。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论