|
1Server IP : 2a02:4780:11:1776:0:2637:29db:10 / Your IP : 216.73.216.175 Web Server : LiteSpeed System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64 User : u641149403 ( 641149403) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u641149403/domains/mistytourandtravel.in/../makemytourindia.com/public_html/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
function haveCommonWord($string1, $string2) {
// Split the strings into arrays of words
$words1 = explode(" ", $string1);
$words2 = explode(" ", $string2);
// Convert all words to lowercase for case-insensitive comparison
$words1 = array_map('strtolower', $words1);
$words2 = array_map('strtolower', $words2);
// Check for intersection of the two arrays
$commonWords = array_intersect($words1, $words2);
// Return true if there is at least one common word, false otherwise
return !empty($commonWords);
}
// Example usage
$string1 = "Dehradun, Uttarakhand, India";
$string2 = "Airport, Jolly grant,";
if (haveCommonWord($string1, $string2)) {
echo "The strings have at least one common word.";
} else {
echo "The strings do not have any common words.";
}
?>