我在 mysql 表中有 2 行。有些数据跨行重复,有些数据在同一行中重复。我想呼应每个独特的价值。
数组如下所示:
Array ( [0] => Array ( [Character1] => Moe Szyslak [Character2] => 0 ) [1] => Array ( [Character1] => Homer Simpson [Character2] => 0 ) [2] => Array ( [Character1] => Homer Simpson [Character2] => ) [3] => Array ( [Character1] => Homer Simpson [Character2] => Marge Simpson )
尝试了各种事情,foreach's
结合 array_unique 等,但没有什么是接近的,所以我想我一定要离开了。预期结果是:
Moe Szyslak Homer Simpson Marge Simpson
编辑:查询在 CI 模型中(是的,我的数据库结构应该更好):
function getCharacter()
{
$query = $this->db->query("SELECT DISTINCT Character1, Character2 FROM clip");
return $query->result_array();
}