fork download
  1. <?php
  2.  
  3. $tmp = '1. Mathematik, LA Bachelor Gymnasien, 2015,'; // => Sonstige
  4. $tmp = '1. Informatik, Bachelor, 2015, 1. Fachsemester'; // => Informatik
  5. $fachrichtung = '';
  6. if (preg_match( '/\d+\.(?P<fach>[\w\s]+)/ius', $tmp, $aMatches )) {
  7. if (true === stripos($tmp, ', LA ') ) {
  8. $fachrichtung = "Lehramt";
  9. } else if ("Informatik" !== trim( $aMatches['fach'] ) && "Physik" !== trim( $aMatches['fach'] )) {
  10. $fachrichtung = "Sonstige";
  11. } else {
  12. $fachrichtung = trim( $aMatches['fach'] );
  13. }
  14. echo $fachrichtung;
  15. }
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
Informatik