I've got an array that looks like this:
Array
(
[0] => Array
(
[id] => abc
[name] => Charlotte
[state] => NC
)
[1] => Array
(
[id] => def
[name] => Tampa
[state] => FL
)
)
What I am trying to do is pull two of the values from each nested array ('id' and 'name'), run a function on them, and return an array that is then nested. So, for each 'id' and 'name,' pass that to "function work($id,$name)," which returns an array, such that the resulting array looks like this:
Array
(
[0] => Array
(
[id] => abc
[name] => Charlotte
[state] => NC
[restaurants] => Array (
[rname] => Good Burger
[rname] => McD
)
)
[1] => Array
(
[id] => def
[name] => Tampa
[state] => FL
[restaurants] => Array (
[rname] => BK
[rname] => White Castle
)
)
)
My searches on here found a few ways of pulling the values from the original arrays (foreach() loop), but I am unsure of the best way to pass these values to a function (array_walk doesn't appear to be an option in this case?), and especially of how to return a nested array into another nested array.
Am glad to provide clarification is need be.