removing some text.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhx
    New Member
    • Jul 2007
    • 14

    removing some text.

    i'm trying to remove a portion of a sentence.

    e.g.

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi mi augue, mollis at, imperdiet in, elementum in, lorem.

    to look like this...

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit... <read more>

    using rtrim() doesn't work on me since the text comes from the database.

    any thoughts on this one is greatly appreciated... thanks.
  • adamalton
    New Member
    • Feb 2007
    • 93

    #2
    There are several ways of doing it. If you want to just allow it to show x number of words then you could split it using substr(). Go to the php manual and type substr into the search box, should take you straight to the right page:
    http://uk2.php.net/manual/en/index.php

    Or if you wanted to split it on a certain word you could use regular expressions to split it up. Look up preg_split (also preg_match, and preg_replace) in the php manual. And here for a brief explanation of regular expressions:
    http://www.regular-expressions.inf o/

    Comment

    • rhx
      New Member
      • Jul 2007
      • 14

      #3
      Originally posted by adamalton
      There are several ways of doing it. If you want to just allow it to show x number of words then you could split it using substr(). Go to the php manual and type substr into the search box, should take you straight to the right page:
      http://uk2.php.net/manual/en/index.php

      Or if you wanted to split it on a certain word you could use regular expressions to split it up. Look up preg_split (also preg_match, and preg_replace) in the php manual. And here for a brief explanation of regular expressions:
      http://www.regular-expressions.inf o/
      thanks a lot adamalton!

      Comment

      Working...