Please help with array_diff()

From: Date: Thu, 08 Aug 2002 22:14:09 +0000
Subject: Please help with array_diff()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111741@lists.php.net to get a copy of this message
Hello! Please have a look at the following sample code and help me out if you can $db = new db_SQL(); $sql = "SELECT Name, Email FROM whatever WHERE whatever=whatever"; $db->query( $sql ); while ($db->next_record()) {
    //This is my first array
    $foo[] = array ("name"=>$db->f("Name"), "email"=>$db->f("Email"));
} $db2 = new db_SQL(); $sql2 = "SELECT Name, Email FROM another_table WHERE foo=bar"; $db2->query( $sql2 ); while ($db2->next_record()) {
    //This is my second array
    $bar[] = array ("name"=>$db2->f("Name"), "email"=>$db2->f("Email"));
} // Now i want to compare the two arrays $diff = array_diff($foo[0], $bar[0]); //And heres where it stops working as it should foreach ($diff as $element) {
    echo $element."<br>";
} What is driving me crazy since more then 7 hours is that it ($element) will only output ONE difference, but i want ALL differences listed, why is this not working? As far as i know i am doing nothing wrong, or am i totally stupid? Thank you very much in advance for your time and help! Best regards from Vienna, Jürgen

« previous php.general (#111741) next »