To find 2 words of the same different phrase participle (to find algorithm ideas)
Statement 1 "CSDN Forum is a very good forum"
Statement 2 "CSDN is a nice jar."
The following results are obtained after the same
Csdn=>2
Forum =>2
is a =>2
Very =>1
Nice =>2.
Jar =>1
------Solution--------------------
PHP Code
$a = ' Csdn Forum is a very good forum '; $b = ' csdn is a good jar ';p Rint_r (Sunday ($a, $b)); function Sunday ($a, $b) {//Check the character set of incoming strings Mb_interna L_encoding (mb_check_encoding ($a, ' utf-8 ')? ' Utf-8 ': ' GBK '); Split the incoming string into an array, mainly for the following code to write up a convenient point $t = Array (); for ($i =0; $i
= count ($a)) break; }elseif ($k) break; }//Check matching case if ($n-$i > 1) {if ($buf) {$r [] = $buf; $buf = "; } $r [] = Join ("', Array_slice ($a, $i, $n-$i)); $i = $n; }else $buf. = $a [$i + +]; if ($BUF) $r [] = $buf; List ($b, $a) = Array ($a, $b); Swap two sets of data, and again}while ($loop-);
Return Array_count_values ($R);}