You are here: Re: First and last line « PHP Programming Language « IT news, forums, messages
Re: First and last line

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация