Sample for loading file (3)

by Luke on December 25th, 2009
No notes
Syntax: PHP
Show lines - Hide lines - Show in textbox - Download
<?
    $data = array();
 
    $lines = file("human_miRNA.txt");
 
    for($i = 0; $i < count($lines); $i += 2) {
        if(strlen($lines[$i]) > 2) {
            $item = split("[ >\n]", $lines[$i]);
 
            $data[] = array(
                'Name' => $item[1],
                'Value' => $item[2],
                'Seq' => chop($lines[$i + 1])
            );
        }
    }
 
    unset($lines);
?>
 
<pre>
<?
    echo "Total: " . count($data) . " lines\n\n";
    print_r($data[5]);
    echo "\n";
    echo $data[5]['Seq'];
?>
</pre>

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS