我有两组数组:
数据:
$data = [
[
'company_code' => 'ABC',
'supplier_codes' => [
'S-2',
'S-3',
'S-5',
],
],
];
来源(来自数据库):
$database = [
'company_code' => 'ABC',
'suppliers' => [
[
'code' => 'S-1',
],
[
'code' => 'S-2',
'reference' => '12345'
],
[
'code' => 'S-3',
],
[
'code' => 'S-4',
'reference' => 'some string',
]
],
];
我需要实现的目标:
$data
中缺少供应商代码但$database
中存在供应商代码,
将其从$database
。$data
中存在供应商代码但$database
中缺少供应商代码,请将其添加到$database
此处示例的输出应如下所示:
$output = [
'company_code' => 'ABC',
'suppliers' => [
[
'code' => 'S-2',
'reference' => '12345'
],
[
'code' => 'S-3',
],
[
'code' => 'S-5',
]
],
];
我正在考虑删除suppliers
子阵列,然后根据supplier_codes
中的数据重建结构。但问题是suppliers
中的某些条目可能包含一个名为reference
的可选字段。
答案 0 :(得分:0)
试试这个
roomListData = {<uuid> : {roomCateghory : Single, number : 2},
<uuid1> : {roomCateghory : Double, number : 2} }
答案 1 :(得分:0)
我最终以这种方式解决了我的问题:
print_r($result);
Array
(
[company_code] => ABC
[suppliers] => Array
(
[0] => Array
(
[code] => S-2
[reference] => 12345
)
[1] => Array
(
[code] => S-3
)
[2] => Array
(
[code] => S-5
)
)
)
的输出:
- (void) textFieldDidBeginEditing:(UITextField *)textField
{
if (textField == self.countryTextField)
{
// pass your countryListArray here in picker view
}
else if (textField == self.cityTextField)
{
// get city for selected country here.
// Call web service for city names.
}
}