PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 27: Write a PHP program to find first character that is different between two strings.


<!DOCTYPE html>
	<title>PHP Progarms</title>
		$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]) ;

If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.