id = (object) array( 'pos' => 0, 'len' => 7 ); // position in string, length $stuobj->name = (object) array( 'pos' => 7, 'len' => 8 ); $stuobj->initials = (object) array( 'pos' => 15, 'len' => 2 ); $stuobj->year = (object) array( 'pos' => 17, 'len' => 4 ); $stuobj->month = (object) array( 'pos' => 21, 'len' => 2 ); $stuobj->day = (object) array( 'pos' => 23, 'len' => 2 ); $stuobj->subject = (object) array( 'pos' => 25, 'len' => 4 ); $stuobj->gender = (object) array( 'pos' => 29, 'len' => 1 ); $student_file = "STUDENTS.DAT"; if ( filesize( $student_file ) <> 0 ) { $file = fopen( $student_file, "r" ); while( !feof( $file ) ) { $student = fgets( $file ); if ( strlen( $student ) > 2 ) { $id = substr( $student, $stuobj->id->pos, $stuobj->id->len ); $name = ucfirst( strtolower( trim( substr( $student, $stuobj->name->pos, $stuobj->name->len ) ) ) ); $initials = substr( $student, $stuobj->initials->pos, $stuobj->initials->len ); $year = substr( $student, $stuobj->year->pos, $stuobj->year->len ); $month = substr( $student, $stuobj->month->pos, $stuobj->month->len ); $day = substr( $student, $stuobj->day->pos, $stuobj->day->len ); $subject = substr( $student, $stuobj->subject->pos, $stuobj->subject->len ); $gender = substr( $student, $stuobj->gender->pos, $stuobj->gender->len ); ?> '; } } fclose($file); } ?>
COBOL Students
IDNameDate of birthSexeClass
Regel is leeg of er zit niets in bestand
http://www.csis.ul.ie/cobol/examples/