Now traverse the number string to find and increment result whenever a digit divides N .
$ result = 0 ; for ( $ i = 0 ; $ i < strlen ( $ N ) ; $ i ++ ) { if ( $ divide [ ( int ) ( $ N [ $ i ] - '0' ) ] == true ) $ result ++ ; } return $ result ; }