Una cosa del genere dovrebbe andar bene, anche se ora non posso provarla
Codice PHP:
if (1 == preg_match('/^(([a-z]+){3}).*(([a-z]+){3})$/i', $testo, $matches)) {
echo 'Prime 3: '.$matches[1];
echo 'Ultime 3: '.$matches[2];
}
else {
// il testo ha meno di 6 parole
}