Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $search = 'griffyn';
- $truth = 'griffin';
- $same = 0;
- $different = strlen($truth);
- $matching = '';
- for($i = 0; $i < strlen($truth); $i++)
- {
- if(isset($search[$i]) && $search[$i] == $truth[$i])
- {
- $same++;
- $different--;
- continue;
- }
- else
- {
- $matching = substr($truth, 0, $same);
- break;
- }
- }
- echo 'Different: ' . $different . '<br>';
- echo 'Same: ' . $same . '<br>';
- echo 'Matching Part: ' . $matching . '<br>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement