<?php
$search_key = 'test_key';
$test_arr = array(
$search_key => 'data',
'inner' => array(
'key' => 'value',
'cities' => array(
'Moscow',
'Minsk',
'Kiev',
),
$search_key => 'second_data',
),
);
array_walk_recursive($test_arr, function (&$item, $key) use ($search_key) {
if ($key == $search_key) {
$item = 'changed';
}
});
print_r($test_arr);