function get_second_words() {
$firstWords = array();
$file = file("data.txt");
foreach ($file as $line) {
if (trim($line) != '') {
$expl = explode(" ", $line);
$firstWords[] = $expl[count($expl) - 1];
}
}
return $firstWords;
}
echo implode(', ', get_second_words());
/*
run:
language , development , programmer , the , Group
*/