从 MySQL 列创建 PHP 数组 [英] Create PHP array from MySQL column
本文介绍了从 MySQL 列创建 PHP 数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mysql_fetch_array
会给我一个获取行的数组.从一列中所有行的值生成数组的最佳方法是什么?
mysql_fetch_array
will give me an array of a fetched row. What's the best way generate an array from the values of all rows in one column?
推荐答案
你可以遍历数组,并创建一个新的数组,如下所示:
you could loop through the array, and create a new one, like so:
$column = array();
while($row = mysql_fetch_array($info)){
$column[] = $row[$key];
//Edited - added semicolon at the End of line.1st and 4th(prev) line
}
这篇关于从 MySQL 列创建 PHP 数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文