You are here: Pulling a synopsis from text « PHP Programming Language « IT news, forums, messages
Pulling a synopsis from text

Posted by crucialmoment on 03/25/06 23:22

Greetings,
I am trying to automatically pull a beginning section from submitted
text and return it with a More.. link. The submitted text is in html
created by FckEditor (http://www.fckeditor.net/).
The trouble I am running into is the cutoff point is often inside of a
tag - ie after an opening <div> but the closing div is cut.
The only idea I have come up with is to build an array of all possible
html tags and search for a close for each but I am hoping there is a
cleaner method. Has anyone attempted such a feat previously?

function getSynop($input="", $more_link="", $synop_size='750') {
$tmp_str = substr($input, 0, $synop_size);
$end_val = strrpos($tmp_str, ">") + 1;
if($end_val < ($synop_size)) {
$end_val = strrpos($tmp_str, ".") + 1;
}
if($end_val < ($synop_size)) {
$end_val = strrpos($tmp_str, ">") + 1;
}
Return substr($input, 0, $end_val) ." <a
href='$more_link'>more...</a>";
}

 

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

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