数组在PHP中消失

Here is my code:

public function pgn_oku() {
    $n=-1;
    $x=-1;  
    $detay="";
    $hamle="";
    $file = fopen("D:\satranc\bielcki\kaleli_roklu_vezirli.pgn","r");

    while(! feof($file)) {
        $n=$n+1;
        $detay[$n]= fgets($file);
        $detay[$n]=trim($detay[$n]);
        if (empty($detay[$n])) {
            $x=$x+1;
            $hamle1[$x]= fgets($file);
            $hamle = explode(' ', $hamle1[$x]);
            print_r(array_values($hamle))."<br>";
        } else  {
            echo $detay[$n]."<br>";
            echo $n."<br>";
        }
    }

    print_r(array_values($detay))."<br><br>";
    echo "<br><br>";
    print_r(array_values($hamle))."<br>";
    echo "<br><br>";

    fclose($file);
}

And this is what I get as a result:

[Event "?"]
0
[Site "?"]
1
[Date "????.??.??"]
2
[Round "?"]
3
[White "?"]
4
[Black "?"]
5
[Result "*"]
6
Array ( [0] => 1.b4 [1] => c5 [2] => 2.bxc5 [3] => d6 [4] => 3.cxd6 [5] => Qxd6 [6] => 4.e3 [7] => Nf6 [8] => 5.c4 [9] => b5 [10] => 6.cxb5 [11] => e5 [12] => 7.b6 [13] => Be7 [14] => 8.bxa7 [15] => O-O [16] => 9.axb8=Q [17] => Bd7 [18] => 10.Qbb3 [19] => Rab8 [20] => 11.Qbc2 [21] => Rfd8 [22] => 12.Qe2 [23] => Rdc8 [24] => 13.Qcd3 [25] => Qe6 [26] => 14.Qf3 [27] => Qd5 [28] => 15.Qfxd5 [29] => Nxd5 [30] => 16.Qxd5 [31] => Rxc1+ [32] => 17.Ke2 [33] => Rbxb1 [34] => 18.Qxd7 [35] => Rxa1 [36] => 19.Nf3 [37] => Rxa2 [38] => 20.Qxe7 [39] => Rcc2 [40] => 21.h4 [41] => Rcb2 [42] => 22.h5 [43] => Rb8 [44] => 23.h6 [45] => Rba8 [46] => 24.Rh5 [47] => R2a7 [48] => 25.Qxe5 [49] => * ) Array ( [0] => ) Array ( [0] => [Event "?"] [1] => [Site "?"] [2] => [Date "????.??.??"] [3] => [Round "?"] [4] => [White "?"] [5] => [Black "?"] [6] => [Result "*"] [7] => [8] => )

Array ( [0] => ) 

The question is that the array $hamle is printed above but not below. I played around with a STATIC declaration but to no avail. Any help will be much appreciated.

NOTE: I am using the CodeIgniter framework.

The file that I am reading is:

[Event "?"] [Site "?"] [Date "????.??.??"] [Round "?"] [White "?"] [Black "?"] [Result "*"] 1.b4 c5 2.bxc5 d6 3.cxd6 Qxd6 4.e3 Nf6 5.c4 b5 6.cxb5 e5 7.b6 Be7 8.bxa7 O-O 9.axb8=Q Bd7 10.Qbb3 Rab8 11.Qbc2 Rfd8 12.Qe2 Rdc8 13.Qcd3 Qe6 14.Qf3 Qd5 15.Qfxd5 Nxd5 16.Qxd5 Rxc1+ 17.Ke2 Rbxb1 18.Qxd7 Rxa1 19.Nf3 Rxa2 20.Qxe7 Rcc2 21.h4 Rcb2 22.h5 Rb8 23.h6 Rba8 24.Rh5 R2a7 25.Qxe5 *

I found the answer as the following=> The code works it goes all the way to the end of the file to be read and at the last moment reads the final line which doesn't appear in copy and paste ( it is just a char I suppose) a break as follows does the trick=>

 $hamle = explode(' ', $hamle1[$x]);
    $GLOBALS['hamleg'] = $hamle;

         break;