爆和爆炸多维数组 [英] Implode and Explode Multi dimensional arrays

查看:114
本文介绍了爆和爆炸多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有递归爆炸和PHP爆多维数组的功能?

Are there any functions for recursively exploding and imploding multi-dimensional arrays in PHP?

推荐答案

您可以通过编写递归函数做到这一点:

You can do this by writing a recursive function:

function multi_implode($array, $glue) {
    $ret = '';

    foreach ($array as $item) {
        if (is_array($item)) {
            $ret .= multi_implode($item, $glue) . $glue;
        } else {
            $ret .= $item . $glue;
        }
    }

    $ret = substr($ret, 0, 0-strlen($glue));

    return $ret;
}

至于爆炸的,这一点,除非你给某种形式结构的字符串,在这种情况下,你都成系列化的境界,对于它的功能已经存在是不可能的。净/手动/ EN / function.serialize.php>连载,的 json_en code http_build_query等等

这篇关于爆和爆炸多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆