PHP MySQLi fetch “array push” overrides data
问题 I have 2 arrays: $arr = []; $tempArray = [ 'val1' => "xxx", 'val2' => 0, 'val3' => 0 ]; Then in my mysql query i fill the temp array with values from the current row and finally push him into the $arr: $stmt->bind_result($tempArray["val1"], $tempArray["val2"], $tempArray["val3"]); while ( $stmt->fetch () ) { array_push($arr, $tempArray); } The Problem is, on every loop the "array_push" overrides the data in the $arr . For example I loop 3 times in the $stmt->fetch() . 1. Loop $tempArray = [