Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php进行数组比较_Php_Arrays - Fatal编程技术网

使用php进行数组比较

使用php进行数组比较,php,arrays,Php,Arrays,代码不会停止运行。我需要比较两个数组以匹配每个字符串。两个大小不同的阵列 第一个阵列: Array ( [0] => '+2+x=1' [1] => '+x+2=1' [2] => 'x+2=1' [3] => '-1+2=7' [4] => '+2-1=7' [5] => '+x+27=3+2' [6] => 'x+27=3+2' [7] => 'x=3'

代码不会停止运行。我需要比较两个数组以匹配每个字符串。两个大小不同的阵列

第一个阵列:

Array ( 
    [0] => '+2+x=1' 
    [1] => '+x+2=1' 
    [2] => 'x+2=1' 
    [3] => '-1+2=7' 
    [4] => '+2-1=7' 
    [5] => '+x+27=3+2' 
    [6] => 'x+27=3+2' 
    [7] => 'x=3' 
    [8] => '+x=3' 
)
第二个阵列:

Array ( 
    [0] => '+x+2=1' 
    [1] => '-1+2=7' 
    [2] => '+x+27=3+2' 
    [3] => '+x=3' 
) 
我的当前代码:(第一个数组=$step\u 1,第二个数组=$arr\u result)

$count1=0;
对于($k=0;$k”;
}  
}
}
提前感谢。

使用该函数,它将返回一个数组,其中包含两个数组的匹配值:

$array1 = ['foo', 'bar', 'abc'];  
$array2 = ['foo', 123, 456, 789, 4654, 'abcdef'];

$matching_values = array_intersect($array1, $array2);
$matching_值将导致

Array
(
    [0] => foo
)
编辑:注意,在FOR-you中使用$k,但增加$i。。。这就是为什么你的代码没有停止

对于($k=0;$k
Array
(
    [0] => foo
)