Initialize a variable to count the number of elements it is a factor of
$ count = 0 ; for ( $ j = 0 ; $ j < sizeof ( $ arr ) ; $ j ++ ) if ( $ arr [ $ j ] % $ i == 0 ) $ count += 1 ; array_push ( $ rank , $ count ) ; array_push ( $ factors , $ i ) ; }