Search Results

Search found 1 results on 1 pages for 'user2984974'.

Page 1/1 | 1 

  • Merge array in a different way in PHP

    - by user2984974
    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?

    Read the article

1