我想從MySQL數據庫的「簡單」數組中獲取列表或電子郵件,所以我可以在PHPmailer中使用它們發送電子郵件。 但是我得到多維數組,而不是數組:PHP使用mysqlli返回「簡單」數組
$query = "SELECT DISTINCT `EmailAddress` FROM `Emails` WHERE `JobID` = 1";
$result = $conn->query($query);
if (!$result) {
printf("Query failed: %s\n", $mysqli->error);
exit;
}
while($row = $result->fetch_row()) {
$rows[]=$row;
}
$result->close();
$conn->close();
var_dump($rows); // This will return array(2) { [0]=> array(1) { [0]=> string(24) "[email protected]" } [1]=> array(1) { [0]=> string(17) "[email protected]" } }
//This is how array should be
$MyV = array("[email protected]","[email protected]");
var_dump($MyV); //this is an array I need to have: array(2) { [0]=> string(11) "[email protected]" [1]=> string(11) "[email protected]" }
非常感謝!
非常感謝!完美運作 – Petrik