小编Rah*_*rma的帖子

递归删除数组键前缀

我有以下格式的数组(每个子数组都有父键作为前缀):

$input = array(
    'seo_text' => array(
        'seo_text_title'       => '',
        'seo_text_description' => '',
        'seo_text_button'      => array(
            'seo_text_button_text' => '',
            'seo_text_button_url'  => '',
            'seo_text_button_new_tab_enabled' => '',
        ),
    ),
);
Run Code Online (Sandbox Code Playgroud)

我想将其转换为以下格式:

$input = array(
    'seo_text' => array(
        'title'       => '',
        'description' => '',
        'button'      => array(
            'text' => '',
            'url'  => '',
            'new_tab_enabled' => '',
        ),
    ),
);
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个递归函数,但是它没有按照预期的方式工作。

php arrays recursion

1
推荐指数
1
解决办法
123
查看次数

标签 统计

arrays ×1

php ×1

recursion ×1