php多表查询数据合并,避免foreach循环嵌套

$memberList = $member->getMemberList();
            $members = [];
            if (is_array($memberList)) {
                foreach ($memberList as $item) {
                    $members[$item["id"]] = $item["nickname"];
                }
            }

            foreach ($result as $item) {
                $item["member_name"] = array_key_exists($item["member_id"], $members) ? $members[$item["member_id"]] : "";
                $list[] = $item;
            }

 

转载于:https://www.cnblogs.com/pcx105/p/9374233.html

你可能感兴趣的:(php多表查询数据合并,避免foreach循环嵌套)