使用PHP 將欄位值擷取到陣列
問題:
問題:問題:
問題:
<code class="php">$stmt = $pdo->prepare("SELECT Column FROM foo"); // Note: Using a LIMIT clause is advised for large tables to avoid performance issues. $stmt->execute(); $array = $stmt->fetchAll(PDO::FETCH_COLUMN); print_r($array);</code>
問題:
<code class="php">$stmt = $mysqli->prepare("SELECT Column FROM foo"); $stmt->execute(); $array = []; foreach ($stmt->get_result() as $row) { $array[] = $row['column']; } print_r($array);</code>
問題:
Array ( [0] => 7960 [1] => 7972 [2] => 8028 [3] => 8082 [4] => 8233 )
以上是如何使用 PHP 將列值提取到數組中?的詳細內容。更多資訊請關注PHP中文網其他相關文章!