I have an array like below
$old = array(
\'a\' => \'blah\',
\'b\' => \'key\',
\'c\' => \'amazing\',
\'d\' => array(
This question is old but since it comes up first on Google I thought I'd add solution.
// Subject
$old = array('foo' => 1, 'baz' => 2, 'bar' => 3));
// Translations
$tr = array('foo'=>'FOO', 'bar'=>'BAR');
// Get result
$new = array_combine(preg_replace(array_map(function($s){return "/^$s$/";},
array_keys($tr)),$tr, array_keys($old)), $old);
// Output
print_r($new);
Result:
Array ( [FOO] => 1 [baz] => 2 [BAR] => 3 )