|
Posted by Nick on 11/24/05 18:01
anne001 wrote:
> Hi
>
> For a class, students are going to run an experiment on line. Each time
> a subject runs, his/her data is appended to one giant text file. Their
> own data set will be just one line starting with the keyword they gave
> as identification.
>
> The faculty does not want the students to be able to download and see
> the giant data file. He wants the students to only download and see the
> data that starts with their own identification tag.
>
> in unix, filtering a file to keep only the line starting with code MCB
> would look something like
> tail -f your_file_name | grep MCB
> from what I read.
<?php
$user = 'MCB'; //get this value from wherever it is you get it
//get datafile as an array of lines
$lines = file('datafile.txt');
// Loop through the lines
foreach ($lines as $line_num => $line)
{
if (strpos($line,$user) === 0) //string found at start of line
echo $line;
}
?>
Navigation:
[Reply to this message]
|