Home >Backend Development >PHP Tutorial > 数据库数据动态随机插入数组.

数据库数据动态随机插入数组.

WBOY
WBOYOriginal
2016-06-13 12:57:23919browse

数据库数据动态随机插入数组...急在线等!!!

本帖最后由 mahuatengBC 于 2013-01-09 11:35:57 编辑 静态的可以写,但是动态的试了N多方法 就是不行...
高手指点指点哈

$totleArr=array();<br />
$totleArr = array_merge(array_fill(0, 20, "ipad mini"), array_fill(0, 50, "无线电压力锅"), array_fill(0, 80, "撒旦撒旦"), array_fill(0, 9850, "未中奖"));

这是静态的代码,可以实现要求...


但是怎么换成动态的数据库数据呢?

------解决方案--------------------
$totleArr = array();<br />
while($row=mysql_fetch_array($rs))<br />
{<br />
  $totleArr = array_merge(array_fill(0, $row['rate'], $row['name']));<br />
}

Statement:
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