TheMerovingian TheMerovingian - 4 months ago 7x
PHP Question

array_key_exist() with array as key

I'm trying to check if in an array there is any value of another array. The function

looks like what I'm searching for, but I don't understand how to give the key value at the function as an array. Here's the code:

$risultato_query_controllo_numero = mysql_query($query_controllo_numero);
$voucher_esistenti = array();

while(($row = mysql_fetch_assoc($risultato_query_controllo_numero))) {
$voucher_esistenti[] = $row['numero'];

Which populates the first array with numbers:

$voucher = range($numero, $numero + $quantita);

Which populates the second array with numbers.

What I need to do now is to check if any of the value in
is present in


You can use the array_intersect function:

$overlap = array_intersect($voucher, $voucher_presenti); 

You can find more examples in the documentation.