- preg_match_all: documentation ( source)
- strtoupper: documentation ( source)
<?php
$flightpaths = 'VIE-CAI
hav-vra
JFK-SYD';
if (!preg_match_all('~^([A-Z]{3})-([A-Z]{3})$~m', strtoupper($flightpaths), $out, PREG_SET_ORDER)) {
echo 'Invalid Entry';
} else {
foreach ($out as $row) {
echo "Destination #1: {$row[1]}\n";
echo "Destination #2: {$row[2]}\n\n";
}
}