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
精彩评论