我需要在php中将一维数组转换为多维数组,还需要将此索引数组转换为关联数组。[0] => 9[1] => Bang Bhasm[2] => 123[3] => 161[4] => 6[5] => Sales[6] => Cash[7] => Sales-GST @12%[8] => Output CGST @6%[9] => 10[10] => Be Fresh Churan[11] => 123[12] => 154[13] => 6[14] => Sales[15] => Cash[16] => Sales-GST @12%[17] => Output CGST @6%我想要这个预期的输出:- [0] Array ( [0] => 9 [1] => Bang Bhasm [2] => 123 [3] => 161 [4] => 6 [5] => Sales [6] => Cash [7] => Sales-GST @12% [8] => Output CGST @6% [9] => 10 )[1] Array( [10] => Be Fresh Churan [11] => 123 [12] => 154 [13] => 6 [14] => Sales [15] => Cash [16] => Sales-GST @12% [17] => Output CGST @6% ) I
1 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
php 中的每个数组都是一个关联数组。如果未定义键,则 php 会自动将数组转换为索引数组。
你可能想要这个:
$single_dimension_array = array(9, 'Bang Bhasm', 123, 161, 6, 'Sales', 'Cash', 'Sales-GST @12%', 'Output CGST @6%', 10, 'Be Fresh Churan', 123, 154, 6, 'Sales', 'Cash', 'Sales-GST @12%', 'Output CGST @6%');
或这个
$multi_dimension_array = array(
array(9, 'Bang Bhasm', 123, 161, 6, 'Sales', 'Cash', 'Sales-GST @12%', 'Output CGST @6%'),
array(10, 'Be Fresh Churan', 123, 154, 6, 'Sales', 'Cash', 'Sales-GST @12%', 'Output CGST @6%'));
这会有所帮助:https : //www.geeksforgeeks.org/php-arrays/
- 1 回答
- 0 关注
- 399 浏览
添加回答
举报
0/150
提交
取消