Array
(
[en_name] => ...........
[en_description] => ...........
[gr_name] => ...........
[gr_description] => ...........
)
如何将此数组转换为二维,如:
Array
(
[en] => Array
(
[name] => ...........
[description] => ...........
)
[gr] => Array
(
[name] => ...........
[description] => ...........
)
)
解决方法:
使用此代码:
$finalArr = array();
foreach($arr as $key => $val) {
$tok = explode('_', $key);
$finalArr[$tok[0]][$tok[1]] = $val;
}