Jump to content
php.lv forumi

found similar parts between to who strings


andre

Recommended Posts

A pašam algoritmu izdomāt slinkums gan jau, ne?

 

<?
function domatch($str1, $str2) {
 $len = strlen($str1);
 for ($i = $len; $i > 1; $i--) {
   for ($j = 0; $j <= $len - $i; $j++) {
     $part = substr($str1, $j, $i);
     if (strstr($str2, $part) !== false) {
       return($part);
     }
   }
 }
 return(false);
}

$str3 = domatch('http://www.asd.lv/index.php?asd=asd', 'http://www.asd.lv/other.php?fsd=fsd');

?>

Link to comment
Share on other sites

×
×
  • Create New...