3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( 'Dup.A.123' => 1, 'D' => 4, ); $replacements = array( 'A.123' => 'A123', 'Dup.A' => 'DD', ); foreach (array_keys($array) as $key) { foreach ($replacements as $from => $to) { if (!strncmp($key, $from, strlen($from))) { $array[$to . substr($key, strlen($from))] = $array[$key]; unset($array[$key]); } } } print_r($array);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [D] => 4 [DD.123] => 1 )
Output for hhvm-3.10.0

Process exited with code 153.