两个数组中的类似项目

时间:2013-09-23 06:11:46

标签: php arrays

考虑以下两个数组作为示例:

$a1=['It is a book.','I like Mongo','Hello World!'];
$a2=['I like MongoDB','Bye World!','It is a book.','I am Here!'];

每个数组项都是一个句子。 $ a2是$ a1的修改版本。我想在$ a1(如果有的话)中找到每个$ a2项目的相应版本。我怎样才能以有效的方式做到这一点?

function foo($firstArray,$modifiedArray){
 // ???
}

期望的结果:(它显示第二个数组中每个项目的状态)

[
0=>['modified',1], //First item in second array is modification of the second item of first array.
1=>['new'],
2=>['intact',0],
3=>['new']
]

我希望将它应用于庞大的数据库,性能对我来说至关重要。

确实,我希望在修订版中跟踪维基百科的文章。

0 个答案:

没有答案