开发者

How to convert one dimensional array into multidimensional?

i have an array like

$arr($name=>"vinu",$street0=>"xxx",$street1=>"yyy").

i need to convert this as

$arr1($name=>"vinu",$street=>arra开发者_Go百科y("xxx","yyy")).

How can i do this?


like

foreach($ary as $k => $v)
    if(preg_match("~(.+?)(\d+)$~", $k, $m))
        $out[$m[1]][$m[2]] = $v;
    else
        $out[$k] = $v;

basically, if a key is "something and digits" put its value into result[something][digits] otherwise simply copy the value into the result array

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜