I am working on a website for baseball game schedules.

The PHP Manual says that mysql_fetch_array is deprecated and that for new development the use of the MySQLi functions are recommended.

I have elected to use the object oriented style (shown below).

I am assigning the fetch_array $Result to the $Row variable. If I put gettype($Row) inside the while loop it says that the type for $Row is array.

However, if I put gettype($Row) just below the closing bracket for the while loop it says the type for $Row is NULL.

I am using $Rows as $Key => $Row in a foreach loop and it is working fine.

I have two questions:

Question 1. Why does gettype($Row) say that the $Row variable is an array while inside the while loop; and then say that the $Row variable is NULL immediately below the closing bracket for the while loop?

Question 2. Am I using proper coding technique using the $Row variable in the foreach loop or should I be using $Value, like $Rows as $Key => $Value, in the foreach loop?

PHP Code:
// Run a query
$Query "SELECT ...";

// Assign query to result variable
$Result $MySQLi -> query($Query);

// Loop through all the records in the result
// Assign each table row array to $Row array
while($Row $Result -> fetch_array())
// Assign $Row array to $Rows array
$Rows[]            =    $Row;

gettype($Row); // says "array array array array"
gettype($Row); // says NULL

// foreach loop using previous array $Row works fine!
foreach($Rows as $Key => $Row)
$Row[0]; // Works great! Prints out all the values in table first column.