gpt4 book ai didi

PHP array_unique 返回重复项

转载 作者:行者123 更新时间:2023-11-28 23:24:07 25 4
gpt4 key购买 nike

<分区>

这是我的表tracks:

+---+--------------------+
| id| tag|
+---+--------------------+
| 1 | dance,|
| 2 | dance,tecno,|
| 3 | dance,hihop,|
| 4 | rap,|
| 5 | country,|
| . | ...|
+---+--------------------+

我试过了($value 是我的查询):

$tags = $this->db->query(sprintf("SELECT `tag`, `id` FROM `tracks` WHERE `tag` LIKE '%s' GROUP BY `tag` DESC LIMIT %s, %s", '%'.$this->db->real_escape_string($value).'%', $this->db->real_escape_string($start), $per_page));

while($row = $tags->fetch_assoc()) {
$rows[] = $row;
}

$tags = explode(',', $row['tag']);
$rows = array_unique(array_map('strtolower', $tags));

foreach($rows as $row) {
if(stripos($row, $value) !== false) {
$tag_output .= '<div class="hashtag-inner">
'.$row.'
</div>';
}
}

从这个例子。预期的输出是:dance, tecno, hiphop, rap, country 带有所有唯一标签而不是我有标签 dance 的多个输出。我的输出有什么问题?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com