【发布时间】:2018-12-12 06:10:11
【问题描述】:
我需要将 mysqli select 语句(具有多行的单个字段)的结果加载到一个数组中,例如:
$post = [318,310,323]
如你所见,我使用了fetch_array():
$posts = [];
.....
$stmt->bind_param("s", $sessien);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array(MYSQLI_NUM))
{
array_push($posts, $row);
}
print_r($posts );
$result->free();
$stmt->close();
$customconn->close();
但在打印 r 时,$posts 正在创建类似这样的东西(看起来像数组中的数组):
Array
(
[0] => Array
(
[0] => 318
)
[1] => Array
(
[0] => 310
)
[2] => Array
(
[0] => 323
)
)
我怎样才能解决这个问题:
$post = [318,310,323]
【问题讨论】: