array_push() vs. $array[] = ....哪个是最快的?
2022-08-30 14:52:59
我需要将从MySQL接收的值添加到数组(PHP)中。以下是我得到的:
$players = array();
while ($homePlayerRow = mysql_fetch_array($homePlayerResult)) {
$players[] = $homePlayerRow['player_id'];
}
这是唯一的方法吗?
另外,以下内容更快/更好吗?
$players = array();
while ($homePlayerRow = mysql_fetch_array($homePlayerResult)) {
array_push($players, $homePlayerRow['player_id']);
}