foreach()中的foreach()

I am trying to open multiple files then split each file by line. I am using this with one foreach() to browse through files and another foreach() inside of it to split the file's lines.

$dir = '../mydir';
$files = scandir($dir, 1);
foreach($files as $input){
    if(($input!==".")&&($input!=="..")){
        $myfile="../mydir/".$input;
        $fh = fopen($myfile, 'r');
        echo $input."... ";
        $input = substr($input,0,-4);
        $FN = "../mydir/out.".$input.".xls";
        $FH = fopen($FN, 'w') or die("Can't open file!");
        $lines = file($myFile);
        foreach($lines as $line) {
        list($OPT1,$OPT2) = explode(",", $line);
            fwrite($FH, $OPT1);     
        }
        echo "Done.";
    }
}

But my $OPT1 is empty.

I suspect your $fh = fopen($myfile,'r') is locking the file so file() can't access it. You don't appear to be using that file handle (indeed you are overwriting the variable later) so just remove that line and you should be good.

EDIT: Oh, and apparently variable names are case-sensetive. You can't interchange $myfile and $myFile.