说我有一系列像这样的句子
我想用php similar_text函数比较每个句子,并用这些对创建一个新数组,这样我就得到一个以大多数相似对和相似比开始的新数组。
答案 0 :(得分:0)
试试这个:
<?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);
?>