Парсер CSV (fgetcsv)

    $handle = fopen($filename, 'r');
    $delim = '~';
    $enclosure = '"';
    $first = true;
    while($line = fgetcsv($handle, 0, $delim, $enclosure)){
        if($first) {
            $keys = $line;
            $first = false;
        } else {
            $row = array_combine($keys, $line);
            ...
        }
    }
    fclose($handle);