Array comparison and corresponding relationship are obtained. how can this problem be solved?

Source: Internet
Author: User
Array comparison and obtain the known correspondence array a: $ a & nbsp; array & nbsp; (& nbsp; 0 & nbsp; & gt; & nbsp; & nbsp; array & nbsp; (& nbsp; packageno & nbsp; & gt; & nbsp; S2Y140805025, & nbsp; & nbsp; & array comparison and correspondence
Known array:

$a = array (
0 =>
array (
'packageno' => 'S2Y140805025',
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4212',
),
1 =>
array (
'packageno' => 'S2Y140805025',
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4214',
),
2 =>
array (
'packageno' => 'SYS140804073',
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4212',
),
3 =>
array (
'packageno' => 'SYS140804073',
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4213',
),
4 =>
array (
'packageno' => 'SYS140731064',
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4154',
),
5 =>
array (
'packageno' => 'SYS140731064',
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4210',
),
6 =>
array (
'packageno' => 'SYS140801090',
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4200',
),
7 =>
array (
'packageno' => 'SYS140801090',
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4210',
),
);


There is a correspondence relationship, such as packageno S2Y140805025 corresponding to lotno 4212,4214 (type is ECS0-235, cust_no is 12654172)

Also known array B:

$b = array (
0 =>
array (
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4211',
),
1 =>
array (
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4212',
),
2 =>
array (
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4213',
),
3 =>
array (
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4214',
),
4 =>
array (
'type' => 'ECS0-235',
'cust_no' => '12654172',
'lotno' => '4216',
),
5 =>
array (
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4154',
),
6 =>
array (
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4200',
),
7 =>
array (
'type' => 'ECS1-713',
'cust_no' => '12657727',
'lotno' => '4210',
),
);


Q: When the types of arrays a and B are the same as those of cust_no, whether the lotno corresponding to packageno in array a is continuous in array B. if not continuous, packageno is displayed.

What should I do?
------ Solution --------------------
Function foo ($ a, $ B ){
Foreach ($ a as $ v ){
$ C [] = array_search ($ v, $ B );
}
For ($ I = 1; $ I If (abs ($ c [$ I]-$ c [$ i-1])! = 1 ){
Return 'nonconsecutive ';
}
}
Return 'continous ';

Contact Us

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.