<?php
Class LRS{
/**
•@param array $texts
•Prints longest repeated substrings for each text */
public static function getAllLRS($texts){
$stringArr = array();
foreach($texts as $string){
$stringArr[] = self::LongestRepeatedSubstring($string);
}
return $stringArr;
}
public function LongestRepeatedSubstring($string){
if ($string == null)
return null;
$string_length = strlen($string);
$substrings = array();
for ($i=0; $i < $string_length; $i++){
$substrings[$i] = substr($string, $i);
}
sort($substrings);
$result = "";
for ($i = 0; $i < $string_length - 1; $i++){
$lcs = self::LongestCommonString($substrings[$i], $substrings[$i + 1]);
if (strlen($lcs) > strlen($result)){
$result = $lcs;
}
}
return $result;
}
function LongestCommonString($a, $b){
$n = min(strlen($a), strlen($b));
$lcs_result = "";
for ($i = 0; $i < $n; $i++){
if ($a[$i] == $b[$i]){
$lcs_result = $lcs_result.$a[$i];
}else{
break;
}
}
return $lcs_result;
}
}
print_r(LRS::getAllLRS(['ABCDEFG','banana','abcpqrabpqpq']));
?>
PHP mail function and mail configuration in XAMPP and sending mail is done from sendmail through localhost. I hope it will help you. mail() function <? php $to = 'dubeynitish22@hotmail.com' ; $subject = 'Test' ; $message = 'Hello' ; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion (); if (! mail ( $to , $subject , $message , $headers )){ echo "Error !!" ; } else { echo "Email Sent !!" ; } ?> 2. php.ini configuration (For SEND-MAIL) [ mail function ] ; For Win32 only . ; http : //php.net/smtp ; SMTP = localhost ; http : //php.net/smtp-port ; smtp_port = 25 ; For Win32 only . ; http : //php.net/sendmail-from ; sendmail_from = me@example . com ; For Unix only . You may supply arguments as well ( default : "sendmail -t -i...
Comments
Post a Comment