I have two arrays in php and I need to make a new array out of them the arrays are…
array(2) {
["required"]=> array(4) {
["broom handle"]=> int(1)
["metal plate"]=> int(1)
["bolt"]=> int(2)
["motivation"]=> int(1)
} ["userItems"]=> array(4) {
["broom handle"]=> string(4) "1000"
["metal plate"]=> string(4) "1000"
["bolt"]=> string(4) "1400"
["motivation"]=> string(4) "1000"
}
}
What I want to do is take the value of userItems and divide it by the value of required where the key matches, I have tried using array_walk and array_map but can never get it right?
You take it from here.
If the order is identical, you can even do it nicely with an
array_map: