I need to get every first word of the lines in my $lines
. So I'm doing an foreach
on every line like this:
foreach ($lines as $n => $line) {
}
But then the next part, I need to grab only the first word. So I did this with exploding on a space like this:
$explode = explode(" ", $line);
echo $explode[0];
But this is very slow when I do it with many lines, is there a better and faster solution then using an explode()
?