PHP - 循环内的数组返回空

I am trying to add data to 2 different MySql tables through a CSV upload. I have been able to retrieve the information and upload part of the information on one table, but I am having issues sending data to the second table. I have come up with the following code:

$i = 0;
//Loop through the csv file
do {
    if ($data[0]) {

        //Store request information
        //Info for Request Table
        $requester_email = $data[0];
        $requester_name = $data[1];
        $client_name = $data[2];
        $client_country = $data[3];
        $opportunity_number = $data[4];
        $machine_quantity = $data[5];
        $severity = $data[6];

        //Store machine values
        //Info for Serial Numbers Table
        $serialType = array();
        $serialModel = array();

            $serialType[$i] = $data[7];
            $serialModel[$i] = $data[8];

    }
    $i++;
} while ($data = fgetcsv($handle,1000,",","'"));

I am having an issue with the array. I have only been able to store the serialType and serialModel from the last line in the csv file. For example, if the csv file has 3 lines of data:

( [0] => Empty [1] => Empty [2] => Last Value ok )

How come I am unable to store the other two values?

Just move

$serialType = array();
$serialModel = array();

before do in your script. While it is still inside the do loop it is just a initialize variable in do - while scope each iteration and clean it up.

$i = 0;

$serialType = array();
$serialModel = array();

while ($data = fgetcsv($handle,1000,",","'")) {
...
    $serialType[$i] = $data[7];
    $serialModel[$i] = $data[8];
    $i++;
};