PHP array comparison solution this is the first array [code = PHP] array & nbsp; 0 & nbsp ;=& gt; & nbsp; & nbsp; array & nbsp; & nbsp PHP array comparison solution
This is the first array.
[Code = PHP]
Array
0 =>
Array
0 => string '20140901' (length = 7)
1 => string '20140901' (length = 7)
2 => string '20140901' (length = 7)
1 =>
Array
0 => string '20140901' (length = 7)
1 => string '20140901' (length = 7)
3 =>
Array
0 => string '20140901' (length = 7)
1 => string '20140901' (length = 7)
[/Code]
This is the second array.
[Code = PHP]
Array
0 => string '20140901' (length = 7)
1 => string '20140901' (length = 7)
2 => string '20140901' (length = 7)
[/Code]
Comparison between the first array and the second array removes different array elements and retains the structure of the first array.
The expected result is as follows:
[Code = PHP]
Array
0 =>
Array
0 => string '20140901' (length = 7)
1 => string '20140901' (length = 7)
1 =>
Array
0 => string '20140901' (length = 7)
3 =>
Array
0 => string '20140901' (length = 7)
[/Code]
Which of the following heroes can help me check it out?
------ Solution --------------------
Data sorting takes much longer than coding!
PHP code
$a = array( 0 => array( 0 => '1000061', 1 => '1000031', 2 => '1000056', ), 1 => array( 0 => '1000056', 1 => '1000049', ), 3 => array( 0 => '1000056', 1 => '1000048', ),); $b = array( 0 => '1000047', 1 => '1000056', 2 => '1000061', );foreach($a as &$v) $v = array_intersect($v, $b);print_r($a);