Home > Backend Development > PHP Tutorial > 下面的数组小弟我该怎么生成~

下面的数组小弟我该怎么生成~

WBOY
Release: 2016-06-13 12:49:08
Original
779 people have browsed it

求教: 下面的数组我该如何生成~~~~~~~~~~~~~~~!
$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 />
}
Copy after login

这样吗? 不过这样报错了。

PHP 多维数组
------解决方案--------------------
whlie($row=...){

  $arr[$row['traffic_type']][] = array("value"=>$row['in_bytes']);
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template