Is it necessary to store the result of explode()
if all it will be used for is a loop?
$lines = explode(PHP_EOL, $data);
foreach ($lines as $line) {
// do stuff
}
Is there any reason not to call it directly within the loop? Will explode()
be called once, or for every iteration?
foreach (explode(PHP_EOL, $data) as $line) {
// do stuff
}