我想将我的复杂数组转换为更简单的数组,以便将转换后的简单数组导出到CSV文件中。目前我的数组结构是这样的:Array([0] => Array ( [_source] => Array ( [block] => Array ( [0] => Kurud ) [district] => Array ( [0] => Dhamtari ) [state] => Array ( [0] => Chhattisgarh ) ) )[1] => Array ( [_source] => Array ( [block] => Array ( [0] => North-Bangeluru ) [district] => Array ( [0] => Bangalore ) [state] => Array ( [0] => Karnataka ) ) ))我想将上面的数组转换为下面给定的格式:array( array("block", "district", "state"), array("Kurud","Dhamtari","Chhattisgarh"), array("North-Bangeluru","Bangalore","Karnataka"))所以键将是第一个元素,然后是每个元素及其数据。这是我尝试过的:foreach ($array as $key => $value) { if (is_array($value)) { $result = array_merge($result); } else { $result[$key] = $value; } } print_r(result);提前致谢...
1 回答
慕的地6264312
TA贡献1817条经验 获得超6个赞
- 1 回答
- 0 关注
- 218 浏览
添加回答
举报
0/150
提交
取消