Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-10-2006, 11:45 AM text parsing
Junior Talker

Posts: 1
Trades: 0
Hello everyone and thanks much for your past help.

I have two pages for an article -- a home page that I want to show only the first few paragraphs for an article that includes a link for the full article and then a page that will display a full article.

My question is: How do I break up the article after say 300 characters and make sure that it breaks up the article at the end of a paragraph? In other words, the script will parse up to 300 characters of the beginning of the article, then break the article off at the end of the nearest paragraph after reaching the 300 character limit. Make sense?

I have written the following code, where it will break up the article at the fourth paragraph, but I would really like to get it where it counts characters instead. Thanks for any help anyone may be able to share.

PHP Code:
<?php if ($RSMiddle1['Body'] != "") {

    
$str $RSMiddle1['Body'];
    
$temp str_replace(chr(13), "<p>"$str);                            $elements explode("<p>"$temp8);
    
$discard array_pop($elements);
    
$new_string =implode("<p>"$elements); 
                                        
    
print_r($new_string);
        }
?>
vzwhaley is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to text parsing
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12737 seconds with 12 queries