Created
June 20, 2019 15:23
-
-
Save pranid/6168ddf089dfb39d80a37d4d10a410fb to your computer and use it in GitHub Desktop.
Compare character change count between string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str_one = "PASS12345"; | |
$str_two = "PASSWOD45"; | |
$str_one_arr = str_split($str_one); | |
$new_arr = str_split($str_two); | |
$arr_intersect = array_intersect($new_arr, $str_one_arr); | |
$arr_changes = array_diff($new_arr, $arr_intersect); | |
$change = abs(sizeof($str_one_arr) - sizeof($arr_intersect)) + sizeof($arr_changes); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment