Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在一段时间内从数据中提取数组_Php_Arrays - Fatal编程技术网

Php 在一段时间内从数据中提取数组

Php 在一段时间内从数据中提取数组,php,arrays,Php,Arrays,我想在我的while中创建一个包含以下数据的数组: while ($fetch = $query->fetch(PDO::FETCH_ASSOC)){ $data1 = $fetch['DEB_Sum']; $data2 = $fetch['DEB_PaymentMethod']; } 请问我怎么做 谢谢。将查询更改为选择所需的列,然后使用fetchAll: $data = $query->fetchAll();

我想在我的while中创建一个包含以下数据的数组:

while ($fetch = $query->fetch(PDO::FETCH_ASSOC)){
  $data1 = $fetch['DEB_Sum'];
  $data2 = $fetch['DEB_PaymentMethod'];
}
请问我怎么做


谢谢。

将查询更改为
选择所需的列,然后使用
fetchAll

$data = $query->fetchAll();