KTH, Matematik, Alexandre Chapovalov
5B1132, Amelia 1 för Farkostteknik
$fin = fopen("results.txt","r"); //open file $found = 0; $markformat = "gu\\.UG-"; while (!feof ($fin)) { $buffer = fgets($fin, 4096); //read line //parse the string $buffer with special mask and put result into array $matches //mask include the input Personal number , so just one entry (or less) should fit if( preg_match("/^(\w+\s\w+)\s+$T6$T4\s+([$markformat]+)\s+([$markformat]+)\s+([$markformat]+)\s+([$markformat]+)\s+([$markformat]+)\s+$/",$buffer,$matches)) { //if string in specified format(that means also that the person number is the right one, //output the result, that was put into array $matches echo "Textat namn $matches[1]
"; echo "Personnummer $T6-$T4
"; echo "L1 L2 L3 Inl Moment
"; for( $i = 2; $i < 7; $i++ ) { echo "Moment".($i-1).": ".$matches[$i]."