| 
 Posted by Hero Wanders on 08/29/05 19:41 
Hello! 
 
> Assuming the lines are separated by \n, you can simply do: 
>  
> $lines = explode("\n", $text); 
> $firstLine = $lines[0]; 
> $lastLine = array_pop($lines); 
 
Be careful with array_pop() here! 
If $lines is used later perhaps the missing line is needed. 
You should either use 
 
$firstLine = $lines[0]; 
$lastLine  = $lines[count($lines)-1]; 
 
or 
 
$firstLine = array_shift($lines); 
$lastLine  = array_pop($lines); 
 
Greetings, 
Hero Wanders
 
[Back to original message] 
 |