KTH, Matematik, Alexandre Chapovalov
5B1133, Amelia 2
$fin = fopen("ResTenta.Amelia2T.txt","r"); //open file $found = 0; $markformat = "gu\\.UG-"; $betygformat = "U345-"; $pointformat = "01234-"; 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+([$pointformat]+)\s+([$betygformat]+)\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 "Bonus: ".$matches[2]."