My tags are showing in the inner foreach loop in the right order.
I would like to comma separate them but am not sure how.
Is there a better way to display my tags without using the second foreach loop?
$people = array();
while($row = mysqli_fetch_array($rs, MYSQLI_ASSOC)){
if(!isset($people[$row["id"]])){
$people[$row["id"]]["id"] = $row["id"];
$people[$row["id"]]["tag"] = $row["tag"];
$people[$row["id"]]["tags"] = array();
}
array_push($people[$row["id"]]["tags"], array("id"=>$row["tags_id"],"tag_name"=>$row["tag"]));
}
foreach($people as $pid=>$p){
echo "(#{$p['id']}) ";
foreach($p["tags"] as $tid=>$t){
echo "<a href='#'>{$t['tag_name']}</a> ";
}
echo "<br><br>";
}
implode()
?