Hamming Distance between two strings | function to calculate Hamming distance ; Driver Code ; function call
< ? php function hammingDist ( $ str1 , $ str2 ) { $ i = 0 ; $ count = 0 ; while ( isset ( $ str1 [ $ i ] ) != ' ' ) { if ( $ str1 [ $ i ] != $ str2 [ $ i ] ) $ count ++ ; $ i ++ ; } return $ count ; } $ str1 = " geekspractice " ; $ str2 = " nerdspractise " ; echo hammingDist ( $ str1 , $ str2 ) ; ? >