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.

first_char.php

<!DOCTYPE html>
<html>
<head>
	<title>PHP Progarms TutorialDuniya.com</title>
</head>
<body>
	<?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");
	?>
</body>
</html>


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.