在下面的代码中:
$sth = $dbh->query('SELECT DISTINCT title,courseId,location from training');
$sth->setFetchMode(PDO::FETCH_ASSOC);
$results = $sth->fetchAll();
$uu = array_unique($results);
echo "<pre>";
print_r($uu);
echo "</pre>";
我只得到 1 个结果print_r($uu);
如果我删除array_unique
所有(30+)行,则返回。(不,并非所有这些都是重复的):)
我究竟做错了什么?
编辑var_dump()
结果:
array(23) {
[0]=>
array(3) {
["title"]=>
string(26) "String Here"
["courseId"]=>
string(1) "8"
["location"]=>
string(1) "1"
}
[1]=>
array(3) {
["title"]=>
string(26) "Another String Here"
["courseId"]=>
string(1) "8"
["location"]=>
string(1) "2"
}
[2]=>
array(3) {
["title"]=>
string(24) "Third String Here"
["courseId"]=>
string(1) "5"
["location"]=>
string(1) "2"
}
ETC...