comparing the contents of two arrays

From: Date: Mon, 24 Jul 2000 17:42:59 +0000
Subject: comparing the contents of two arrays
Groups: php.general 
Request: Send a blank email to php-general+get-7937@lists.php.net to get a copy of this message
hi, i've got two arrays of which i'm trying to compare the content. One of them is indexed by numbers (for eg $array1[1]= "foo" ) the other is indexed with text (as in $array2["foo"] = "bar";) These are passed from a database and a form respectively. How can I compare the contents of the two arrays and, for elements of $array1 for which there are no values set in $array2, (though $array1[5] = "wotsit", there is no value set for $array2["wotsit"] ), set a default value ? (say $array2["wotsit"] = "default"; ) ? cheers, nick

« previous php.general (#7937) next »