Recursively left trim a specific character from keys

Try this:

function replaceKeys(array $input) {

    $return = array();
    foreach ($input as $key => $value) {
        if (strpos($key, '_') === 0)
            $key = substr($key, 1);

        if (is_array($value))
            $value = replaceKeys($value); 

        $return[$key] = $value;
    }
    return $return;
}

So this code:

$arr = array('_name' => 'John', 
             'ages'  => array(
                  '_first' => 10, 
                  'last'   => 15));

print_r(replaceKeys($arr));

Will produce (as seen on codepad):

Array
(
    [name] => John
    [ages] => Array
        (
            [first] => 10
            [last] => 15
        )

)