3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $settings = array( 'simple_value1' => array('nodenodenodenodenodenodenodenode'), 'menu-template-24-prim' => array('menu-template-24-prim' => 24), 'frontpage' => 'node', ); $domains = array( 24 => 26, 55 => 58, 25 => 51, 53 => 29, ); foreach ($domains as $old_id => $cur_id) { $old_menu_prim = 'menu-template-' . $old_id . '-prim'; $old_menu_sec = 'menu-template-' . $old_id . '-sec'; $cur_menu_prim = 'menu-template-' . $cur_id . '-prim'; $cur_menu_sec = 'menu-template-' . $cur_id . '-sec'; // Replace old menu-template-55-prim settings for menu-template-58-prim. foreach ($settings as $key => $value) { if (is_array($value) && !empty($value[$old_menu_prim])) { $settings[$key][$old_menu_prim] = 0; $settings[$key][$cur_menu_prim] = $cur_menu_prim; } elseif (is_array($value) && !empty($value[$old_menu_sec])) { $settings[$key][$old_menu_sec] = 0; $settings[$key][$cur_menu_sec] = $cur_menu_sec; } } } print_r($settings);
based on hCCFS
Output for 4.3.0 - 7.2.0
Array ( [simple_value1] => Array ( [0] => nodenodenodenodenodenodenodenode ) [menu-template-24-prim] => Array ( [menu-template-24-prim] => 0 [menu-template-26-prim] => menu-template-26-prim ) [frontpage] => node )