-2

I have a txt file.. It is a result of GFF file... can any one of you point me how to find a specific string and the value next to it in another column?

4

2 回答 2

0

您需要阅读文件(通常是逐行)以找出里面的内容。

于 2013-07-05T13:48:25.260 回答
0

好吧,我假设您的 GFF 文件符合这些规范
在这种情况下,您可以使用以下命令逐行读取文件(并拆分列以获取数组):

// Open the file
$file = fopen('your_file.txt', 'r');

// Go over the lines
while (!feof($file)) {
    $line = fgets($file);
    $parts = preg_split('/\s+/', $line);

    // Check if cds is found in one of the parts
    $cds = search('cds', $parts);

    // We found one
    if ($cds !== false) {
        // Get the next value
        $value = $parts[$cds + 1];

        // Do something with it             
    }

}
于 2013-07-05T14:03:32.143 回答