I have an array structure like below
Array
(
[1] => Dept1
[2] => Dept2
[3] => Dept3
)
And I have another Array as below
Array
(
[1] => Array
(
[user1] => 58
[user3] => 75
)
[2] => Array
(
[user6] => 162
)
[3] => Array
(
[user7] => 2
[user8] => 126
[user9] => 148
)
)
I want
Array
(
[Dept1] => Array
(
[user1] => 58
[user3] => 75
)
[Dept2] => Array
(
[user6] => 162
)
[Dept3] => Array
(
[user7] => 2
[user8] => 126
[user9] => 148
)
)
The numbers in 2nd array are the department numbers. And their values are present in the first array. I want to replace the department number in second array with value from first array.
I have tried with array_replace() but don't get successful.
Please help
Thanks in advance
DeptXs? You can only use numbers and Strings as keys in an array.