andre Posted January 15, 2004 Report Share Posted January 15, 2004 kaa atrast vienaadas dalas starp diviem stringiem piemeeram: $str1="http://www.asd.lv/index.php?asd=asd"; $str2="http://www.asd.lv/other.php?fsd=fsd"; rezultaats: $str3="http://www.asd.lv/"; Link to comment Share on other sites More sharing options...
laacz Posted January 16, 2004 Report Share Posted January 16, 2004 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 More sharing options...
Recommended Posts