Forum Moderators: coopster
I have just completed a CMS in PHP/MySQL and the final task I'm struggling with is controlling the amount of content returned.
In my 'Articles' section I call:
eval ( StripSlashes( $thisDoc["xml_content"] ) );
Which is the actual document content itself (which may or may not contain more PHP). My problem is how to control the amount of content returned. Some articles should be spread over 3 or 4 pages, not just 1.
Is there a way I can:
a) Restrict the content returned without having to count the first 2000 characters or something similar?
b) Return content without splitting in the middle of a potential PHP tag?
cheers,
asp
$content = substr($xml_content,0,2000); Another idea would be to place some kind of "special separators" that you can use to identify blocks of content and display as needed.
b) is not so easy.
You have to find out where the PHP and check if it is withing the first X characters you want from the content and cut it there.
Maybe something like:
$where_php = strpos($xml_content,"<?");
if ($where_php!==false) {
// not found, there is no PHP in this one
$content = substr($xml_content,0,2000);
} else {
// there is PHP, where is it?
if ($where_php>2000) {
$content = substr($xml_content,0,$where_php);
} else {
$content = substr($xml_content,0,2000);
}
}