Array1
(
[0] => Array
(
[accNo] => 000000
[accTypeCode] => C
[accName] => something
[accCurrency] => BDT
[branchCode] => 101
[branchName] => empty
)
[1] => Array
(
[accNo] => 0000
[accTypeCode] => C
[accName] => something
[accCurrency] => BDT
[branchCode] => 101
[branchName] => empty
)
[2] => Array
(
[accNo] => 0000
[accTypeCode] => L
[accName] => something
[accCurrency] => BDT
[branchCode] => 999
[branchName] => empty
)
[3] => Array
(
[accNo] => 00000
[accTypeCode] => L
[accName] => something
[accCurrency] => BDT
[branchCode] => 999
[branchName] => empty
)
)
Array2
(
[0] => Array
(
[branchCode] => 101
[ATMName] => Agrabad
)
[1] => Array
(
[branchCode] => 999
[ATMName] => Azimpur
)
)
这些是我的两个数组array1和array2。现在我需要做的是在array1中,其中branchCode为101,其中branchName empty
将被array2的ATMName
替换,其中branchCode为101,同样为999.希望我的问题清楚...
答案 0 :(得分:0)
尚未尝试过,但大多数情况下应该可以使用。
for($c1=0;$c1<count($array1);$c1++)
{
if($array1[$c1]['branchName']=="empty")
{
for($c2=0;$c2<count($array2);$c2++)
{
if($array1[$c1]['branchCode']==$array2[$c2]['branchCode'])
{
$array1[$c1]['branchName']=$array2[$c2]['ATMName'];
}
}
}
}
请告诉我它是否有效!