假设我有很多这样的句子
,我跳了一跳”G 211
我想用php similar_text函数比较每个句子,并用这些对创建一个新的数组,这样我就可以得到一个新的数组,首先是最相似的对和相似度。
发布于 2011-08-04 09:36:57
试试这个:
<?php
$words = array( "great white fox jumped", "I like it like that", "great white hen eats", "Today is friday", "hahaha, I did a great
jump");
$count = 0;
for ($i=0;$i<count($words)-1;$i++){
for ($j = $i+1;$j<count($words);$j++){
$arr[$count][0] = similar_text($words[$i], $words[$j]);
$arr[$count][1] = $words[$i];
$arr[$count][2] = $words[$j];
$count++;
}
}
rsort($arr);
var_dump($arr);
?>https://stackoverflow.com/questions/6938561
复制相似问题