PHP arrayKeysKebab2Camel()

1 개요[ | ]

PHP arrayKeysKebab2Camel()
function arrayKeysKebab2Camel($input)
{
    $result = [];
    foreach ($input as $k => $v) {
        $k = lcfirst(str_replace('-', '', ucwords($k, '-')));
        if (is_array($v)) $v = arrayKeysKebab2Camel($v);
        $result[$k] = $v;
    }
    return $result;
}

$arr = ['foo-bar'=>'hello-world','alice-bob-carol'=>['apple-banana'=>'melon']];
print_r(arrayKeysKebab2Camel($arr));

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}