Determine if a string has all Unique Characters | PHP program to illustrate string with unique characters using brute force technique ; If at any time we encounter 2 same characters , return false ; If no duplicate characters encountered , return true ; Driver Code
< ? php function uniqueCharacters ( $ str ) { for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { for ( $ j = $ i + 1 ; $ j < strlen ( $ str ) ; $ j ++ ) { if ( $ str [ $ i ] == $ str [ $ j ] ) { return false ; } } } return true ; } $ str = " GeeksforGeeks " ; if ( uniqueCharacters ( $ str ) ) { echo " The ▁ String ▁ " , $ str , " ▁ has ▁ all ▁ unique ▁ characters STRNEWLINE " ; } else { echo " The ▁ String ▁ " , $ str , " ▁ has ▁ duplicate ▁ characters STRNEWLINE " ; } ? >