TRying to export my rss feed. For one of my rss tags I have <preview> where it will display the first sentence of a string.

How do I go about this? From a string of a article, I want to have just the first sentence saved as a new string.

    finally found a link for this, however sometimes it will say L.A. in the sentence anyway to overcome that?

    Advanced: Return all data BEFORE a given character/string

    I can also print all of the data that occurs before a certain character or string component occurs. This is an advanced technique that requires 2 functions: substr() and strops(). Currently, my $string variable consists of two sentences. By using a clever combination of substr() and $strpos, I can cut off the entire second sentence, leaving me with only the first.

    <?php
    $string = "The Boston Red Sox lost because of poor pitching, bad defense, and a lack of offense. That doesn’t leave much, does it?";
    $newstring = substr($string, 0, strpos($string, "."));
    echo($newstring);
    ?>

    This would print:
    The Boston Red Sox lost because of poor pitching, bad defense, and a lack of offense

      Write a Reply...