0

I have an array like this:

$out_data = array(
  'home' => [
    'city' => 'Miami',
    'state' => 'FL',
    'location' => [
      'lat' => '40.00',
      'long' => '50.00'
    ]
  ],
  'work' => [
    'main' => [
      'role' => 'cheif',
      'address' => 'Miami, FL'
    ],
    'hobby' => [
      'role' => 'painter',
      'address' => null
    ]
  ],
  'age' => 68
);

I need to make a function, that when you pass two options: "work\new", [‘role’ => ‘new_work_role’, ‘address’ => ‘homeland’ ], this array was carried to out adding.

The depth of the array is unknown. And function can to add array to 'work\add\new\new1' or 'secret\project1\role\status' or etc

fafl
  • 7,222
  • 3
  • 27
  • 50
Siricks
  • 401
  • 1
  • 4
  • 5
  • 1
    Possible duplicate of [How to search by key=>value in a multidimensional array in PHP](http://stackoverflow.com/questions/1019076/how-to-search-by-key-value-in-a-multidimensional-array-in-php) – Haridarshan Dec 04 '16 at 09:13
  • Why are `$out_data["home"]` for access and `$out_data["work"]["role"] = "new_work_role";` for adding new entries not enough? – fafl Dec 04 '16 at 09:17
  • Becouse the depth of the array is unknown, and i nedd to add someone to 'work\new\secret_job\project_1' – Siricks Dec 04 '16 at 09:20
  • Does it have to be the same function? Why not have one for reading and one for adding? – fafl Dec 04 '16 at 10:05

0 Answers0