下面的数组小弟我该怎么生成~
Jun 13, 2016 pm 12:49 PM
求教: 下面的数组我该如何生成~~~~~~~~~~~~~~~!
$traffic_type $in_bytes
18 2011110
19 1999110
18 1923832
19 2893823
其中$traffic_type不只有18和19,种类数不确定,
上面有很多行那样的数据。我想生成如下数组:
{
{18:{{"value"=>"2011110"},{"value"=>"1923832"}}
{19:{{"value"=>"1999110"},{"value"=>"2893823"}}
}
上面数组可能写得不对,不过大概就是这么个意思。
在while循环里面应该怎么生成上面的数组?
whlie(){<br /> $arr_data_by_prote.$traffic_type[] = array("value"=>$in_bytes);<br /> $arr.$traffic_type[] = array("value"=>$in_bytes);<br /> }
这样吗? 不过这样报错了。
------解决方案--------------------
whlie($row=...){
$arr[$row['traffic_type']][] = array("value"=>$row['in_bytes']);
}

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
