I have these two arrays:
$array1 = array( '0' => 'apple', '1' => '' , '2' => 'cucumber' );
$array2 = array( '0' => '', '1' => 'bmw', '2' => 'chrysler' );
if I do this to merge these arrays:
$result_arr = array_merge($array1, $array2);
print_r( count ( array_filter($result_arr) ) );
the output would be 4.
However, I need to get the number 3. So, when there are two things on the same position (same key) count it only once.
Is it possible to merge/count elements in arrays like that?