I\'ve tried a lot of potential solutions, but none of them are working for me. The simplest one:
$file = file(\'list.html\');
array_pop($file);
Remove first and last line of a variable in PHP:
Using phpsh interactive shell:
php> $test = "line one\nline two\nline three\nline four";
php> $test = substr($test, (strpos($test, "\n")+1));
php> $test = substr($test, 0, strrpos($test, "\n"));
php> print $test;
line two
line three
You might have meant "The last non blank line". In that case do this:
Notice that there are three blank lines after the content. This gets rid of those lines before removing the last:
php> $test = "line one\nline two\nline three\nline four\n\n\n";
php> $test = substr($test, 0, strrpos(trim($test), "\n"));
php> print $test;
line one
line two
line three