0

I am using this code to get all key and values from multi dimensional array but could not send them to an array to outside function, sure I am missing some thing.

$users = array();
function myfunction($value,$key)
{
    $users[$key] = $value;     
}            
array_walk_recursive($data['userlevel3'],"myfunction");
techansaari
  • 375
  • 1
  • 5
  • 20
  • What does `send them to an array` mean? Can you give an example input/output? It looks like you just want to copy an array: `$data = [...]; $otherArray = $data;` – Xatenev Nov 29 '18 at 07:27
  • In your function you can either return the new array, include `use ($users)` to allow it to access the variable or pass by reference (`&$users`). Please don't use `global`. – Nigel Ren Nov 29 '18 at 07:37

0 Answers0