我有两个数组如下
数组1
Array
(
[0] => Array
(
[ps_id] => 5
[product_id] => 2
[supplier_id] => 25
[cost] => 789.00
[name] => Mahesh
)
[1] => Array
(
[ps_id] => 6
[product_id] => 2
[supplier_id] => 2
[cost] => 12345.00
[name] => mayank
)
[2] => Array
(
[ps_id] => 7
[product_id] => 2
[supplier_id] => 1
[cost] => 123456.00
[name] => abc
)
[3] => Array
(
[ps_id] => 10
[product_id] => 2
[supplier_id] => 8
[cost] => 12000.00
[name] => mayank1
)
)
数组2
Array
(
[0] => Array
(
[suppliers] => Mahesh
[suppliers_cost] => 789.00
)
[1] => Array
(
[suppliers] => mayank
[suppliers_cost] => 12345.00
)
[2] => Array
(
[suppliers] => mayank1
[suppliers_cost] => 12000.00
)
[3] => Array
(
[suppliers] => testtetstet
[suppliers_cost] => 123123
)
)
我想通过suppliers
和name
键
表示这两个键的值是否与存储到一个新数组中的值相同,如果这些键不匹配,则它们将存储新的不同数组。
或者两个数组可能都有不同数量的键
我曾尝试过以下
foreach ($existsProductSupplier as $key => $value) {
if (isset($supplier_data[$key])) {
}else{
$supplier_data[$key]['suppliers']='';
$supplier_data[$key]['suppliers_cost']='';
}
}
foreach ($supplier_data as $key => $value) {
if(in_array($value['suppliers_cost'],$existsProductSupplier[$key])){
//echo "string";
// print_r($value);
}else{
echo "string";
//print_r($value);
}
}
答案 0 :(得分:0)
试试这段代码它会帮助你
initialized(autocomplete: any) {
this.autocomplete = autocomplete;
}
placeChanged(place) {
this.address = {};
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
this.address[addressType] = place.address_components[i].long_name;
}
this.ref.detectChanges();
}