有比strpos()循环更好的方法吗?是否有一个本地php函数来查看一个值的数组是否在另一个数组中?
不是我正在寻找部分匹配而不是in_array()类型的方法。
例如针和干草堆和期望的回报:
$needles[0] = 'naan bread';
$needles[1] = 'cheesestrings';
$needles[2] = 'risotto';
$needles[3] = 'cake';
$haystack[0] = 'bread';
$haystack[1] = 'wine';
$haystack[2] = 'soup';
$haystack[3] = 'cheese';
//desired output - but what's the best method of getting this array?
$matches[0] = 'bread';
$matches[1] = 'cheese';
即:
magic_function($大海捞针,%$针%)!
[array_intersect](http://www.php.net/manual/en/function.array-intersect.php) – hsz 2010-04-21 18:21:31
不,不会比'bread'针对'烤饼bread'。 OP似乎在寻找通配符匹配功能。 – 2010-04-21 18:22:19
这将适用于非完全匹配吗? – Haroldo 2010-04-21 18:23:06