TheMerovingian TheMerovingian - 1 year ago 71
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

Answer Source

You can use the array_intersect function:

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

You can find more examples in the documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download