# PHP array comparison solution

Source: Internet
Author: User
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);`
Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.