Skip to content

Instantly share code, notes, and snippets.

@pranid
Created June 20, 2019 15:23
Show Gist options
  • Save pranid/6168ddf089dfb39d80a37d4d10a410fb to your computer and use it in GitHub Desktop.
Save pranid/6168ddf089dfb39d80a37d4d10a410fb to your computer and use it in GitHub Desktop.
Compare character change count between string
<?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