Write a PHP script to find the first character that is different between two strings.
String1 : 'football'String2 : 'footboll'
<?php $str1 = 'football'; $str2 = 'footboll'; $str_pos = strspn($str1 ^ $str2, "\0"); printf('First difference between two strings at position %d: "%s" vs "%s"', $str_pos, $str1[$str_pos], $str2[$str_pos]); printf("\n"); ?>
Sample Output:
First difference between two strings at position 5: "a" vs "o"
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer