I have two same-sized arrays $array1
and $array2
, both with the usual consecutive numerical keys. $array1
contains numbers, $array2
contains text. I cannot change this structure to accommodate multi-dimensional arrays or what.
Without going through the whole array, how do I get the keys i
of the elements in $array2 where
$array1[i]
is a number; BUT$array2[i]
is empty?
For example:
// numbers
$array1 = array(NAN, NAN, 1, 0, 3.5, NAN, 2, 4, 0.5);
// text
$array2 = array(FALSE, FALSE, "abc", "abc", FALSE, FALSE, "text", "abc", FALSE);
expected result:
// keys of $array2 where $array1[i] is a number and
// $array2[i] is empty/null/false
Array
(
[0] => 4
[1] => 8
)
I've been trying to implement array_keys()
and array_udiff()
and other PHP array functions to do this but I just can't.
Help, guys, thanks!