Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从MySQL查询中删除PHP数组中的重复结果_Php_Mysql_Arrays_Duplicate Removal - Fatal编程技术网

从MySQL查询中删除PHP数组中的重复结果

从MySQL查询中删除PHP数组中的重复结果,php,mysql,arrays,duplicate-removal,Php,Mysql,Arrays,Duplicate Removal,我正在寻找一种方法,可以从结果MySQL查询中删除PHP数组中的重复值。到目前为止,我所拥有的内容提供了我想要的查询,但始终显示所有重复项。我需要为导航菜单删除它们。任何帮助都将不胜感激 这就是我目前所拥有的 $c_search = mysql_query("SELECT * FROM members WHERE interest1 LIKE '%$input%' or interest2 LIKE '%$input%' or interest3 LIKE '%$input%'"); $arra

我正在寻找一种方法,可以从结果MySQL查询中删除PHP数组中的重复值。到目前为止,我所拥有的内容提供了我想要的查询,但始终显示所有重复项。我需要为导航菜单删除它们。任何帮助都将不胜感激

这就是我目前所拥有的

$c_search = mysql_query("SELECT * FROM members WHERE interest1 LIKE '%$input%' or interest2 LIKE '%$input%' or interest3 LIKE '%$input%'");
$array = Array();
while($rows = mysql_fetch_assoc($c_search)) {
array_push($array, $rows['interest1']);
array_push($array, $rows['interest2']);
array_push($array, $rows['interest3']);
for($i=0; $i<count($array); $i++) {
echo $array[$i] . "\n";
}
}
我尝试过将MySQL查询更改为使用DISTINCT,但没有成功。 我试着使用array\u unique$array,SORT\u STRING,没有运气。
我不知道埃利斯要尝试什么。请提供帮助,谢谢。

选项之一:手动创建阵列,执行“检查是否”!在_array$array

中,问题可能在于sql查询。请举一个最终数组和所需数组的示例。为什么数组不唯一?这很奇怪。DISTINCT会起作用,但取决于你在哪里使用它。你需要选择不同的兴趣1,不同的兴趣2。。。来自$c_search=mysql_query从interest1类似“%$input%”的成员中选择不同的interest1;虽然$rows=mysql\u fetch\u assoc$c\u search{$result=$rows['interest1'];echo$result.\n;}这适用于一行查询,但我甚至没有想到这一点。对php来说还是有点陌生。但这很好。另外,我确实检查了我的MySQL查询,但它不起作用。我没有先测试,对自己太有信心了。劳伦斯·切隆提到的独特作品。感谢大家的帮助和快速反应。