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 ';