如何将下面的所有数组与相同的索引号组合,然后检查这些组合数组是否包含某个单词?
Array
(
[1] => text1
[2] => text2
[3] => text3
[4] => text4
)
Array
(
[1] => more text1
[2] => more text2
[3] => more text3
[4] => more text4
)
Array
(
[1] => even more text1
[2] => even more text2
[3] => even more text3
[4] => even more text4
)
答案 0 :(得分:1)
答案 1 :(得分:0)
http://php.net/manual/en/function.array-merge.php
然后
http://www.php.net/manual/en/function.in-array.php
in_array( 'theword', array_merge ( $array1, $array2, $array3 ) );
答案 2 :(得分:0)
if(in_array('certain word', array_merge($array1, $array2, $array3))
{
echo 'Found a match';
}
答案 3 :(得分:0)
$combined = array_map(function ($a1, $a2, $a3) { return "$a1 - $a2 - $3"; }, $array1, $array2, $array3);
foreach ($combined as $string) {
if (strpos($string, 'some word') !== false) {
echo "'$string' contains 'some word'";
}
}
答案 4 :(得分:0)
如果我的问题正确,我相信这就是你想要实现的目标
final_array=array();
foreach ($arr1 as $key=>$value)
{
final_array[$key]=final_array[$key].$value;
}
foreach ($arr2 as $key=>$value)
{
final_array[$key]=final_array[$key].$value;
}
foreach ($arr3 as $key=>$value)
{
final_array[$key]=final_array[$key].$value;
}
foreach ($final_array as $key=>$value)
{
if(strstr($value,$search_keyword))
{
echo "match found for :$search_keyword"
}
}