<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>echo &#8211; Blogvaria</title>
	<atom:link href="https://blog.evaria.com/key/echo/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.evaria.com</link>
	<description>The personal pages</description>
	<lastBuildDate>Wed, 23 Jun 2010 09:48:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
<site xmlns="com-wordpress:feed-additions:1">1077093</site>	<item>
		<title>Using PHP to print only the first sentence</title>
		<link>https://blog.evaria.com/2010/using-php-to-print-only-the-first-sentence/</link>
		
		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Wed, 23 Jun 2010 09:48:39 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[print]]></category>
		<guid isPermaLink="false">http://blog.evaria.com/?p=1250</guid>

					<description><![CDATA[Ever wanted to pull just the first sentence of a text and print it? If yes, this is for you. Simply add the following code (in PHP) to your page/system &#8230; ]]></description>
										<content:encoded><![CDATA[<p>Ever wanted to pull just the first sentence of a text and print it? If yes, this is for you.</p>
<p>Simply add the following code (in PHP) to your page/system before the actual HTML stuff begins:</p>
<pre>< ?php
function getFirstSentence($string)
{
    // First remove unwanted spaces - not needed really
    $string = str_replace(" .",".",$string);
    $string = str_replace(" ?","?",$string);
    $string = str_replace(" !","!",$string);
    // Find periods, exclamation- or questionmarks with a word before but not after.
    // Perfect if you only need/want to return the first sentence of a paragraph.
    preg_match('/^.*[^\s](\.|\?|\!)/U', $string, $match);
    return $match[0];
} 
?></pre>
<p>Then call the function somewhere on the page where you want the text to appear:</p>
<pre>< ?php
    // The $string below could/should be a text string pulled from your database or similar
    $string = "Lentence oneasdasd asd asd asdasd, ?. Sentence two? Sentence three! Sentence four.";
    echo getFirstSentence($string);
?></pre>
<p>Comes in handy for search result pages, page titles and similar listings.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1250</post-id>	</item>
	</channel>
</rss>
