traverse for every elements and checks the maximum N that is present in both the arrays
$ x = $ N - 1 ; for ( ; $ x >= 0 ; $ x -- ) if ( $ first [ $ x ] && $ second [ $ x ] ) break ; echo $ first [ $ x ] . " ▁ " . $ second [ $ x ] . " STRNEWLINE " ; }