Join names

Recently I start join couple's names

Larry and Eva.
After the join, we have
Larva, Lava(hot...) and Vary

Peter and Alex
After the join, we have
Telex, Petal and Alter

Matt and Angela
mage, lama, mange, mangel

It work with other strings too... like
Chao and Evil
...Hail!!!

Sweet and Ass
We have...
Asset
ok... that is a lame one...
I would go with Swass. But it's not a word, so my script will not show it.

Yeah, I wrote a naive script to suggest possible names from a dictionary. It's slow...

//$s1 = first person's name, $s2 second person's name
//$a, a array of words, just google dictionary.txt
//$m minimal size of sub string used from each name
//$x minimal size of the output word
function joinname($s1,$s2,$a,$m=2,$x=4){
	$s1 = strtolower($s1);
	$s2 = strtolower($s2);
	$l1 = strlen($s1)+1;
	$l2 = strlen($s2)+1;
	if($m<1){
		$m=1;
	}
	for($i=$m;$i<$l1;$i++){
		for($i1=0;$i1<$l1-$i;$i1++){
			$t = substr($s1,$i1,$i);
			for($j=max($m,$x-$i);$j<$l2;$j++){
				for($j1=0;$j1<$l2-$j;$j1++){
					$t2 = substr($s2,$j1,$j);
					if(in_array($t.$t2,$a)){
						$r[] = $t.$t2;
					}
					if(in_array($t2.$t,$a)){
						$r[] = $t2.$t;
					}
				}
			}
		}
	}
	return $r;
}

Comments

Post new comment

  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <fn>
  • Lines and paragraphs break automatically.
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Mathematical equations and graphs can be added between [tex] and [/tex], [graph] and [/graph] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Honey Pot that kill bots