MySQL Forums
Forum List  »  PHP

Re: array intersect
Posted by: Chis Florinel
Date: September 19, 2005 07:50AM

array_intersect() function will return the common values found in those 2 arrays, key is ignored.

so

$array1 = array('key_1' => "sameValue");
$array2 = array('key_2' => "sameValue");


$commonResults = array_intersect($array1, $array2);
var_dump($commonResults);

will output:
array(1) {
["key_1"]=>
string(9) "sameValue"
}


array_intersect_assoc() will test if the keys AND the values are the same.

$commonResults = aarray_intersect_assoc($array1, $array2);
var_dump($commonResults);

will output an empty array:
array(0) {
}

Hope it helps

Options: ReplyQuote


Subject
Written By
Posted
September 18, 2005 10:12AM
Re: array intersect
September 19, 2005 07:50AM
September 19, 2005 10:06AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.