Numbers having Unique ( or Distinct ) digits | Function to print unique digit numbers in range from l to r . ; Start traversing the numbers ; Find digits and maintain its hash ; if a digit occurs more than 1 time then break ; num will be 0 only when above loop doesn 't get break that  means the number is unique  so print it. ; Driver code
< ? php function printUnique ( $ l , $ r ) { for ( $ i = $ l ; $ i <= $ r ; $ i ++ ) { $ num = $ i ; $ visited = ( false ) ; while ( $ num ) { if ( $ visited [ $ num % 10 ] ) $ visited [ $ num % 10 ] = true ; $ num = ( int ) $ num / 10 ; } if ( $ num == 0 ) echo $ i , " ▁ " ; } } $ l = 1 ; $ r = 20 ; printUnique ( $ l , $ r ) ; ? >