<?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>php &#8211; Blogvaria</title>
	<atom:link href="https://blog.evaria.com/key/php/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>
		<item>
		<title>Another browser detection method</title>
		<link>https://blog.evaria.com/2008/another-browser-detection-method/</link>
		
		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Fri, 25 Apr 2008 12:49:56 +0000</pubDate>
				<category><![CDATA[CSS & Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[browser detection]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://blog.evaria.com/?p=813</guid>

					<description><![CDATA[First let me emphasise that I&#8217;m not a big fan of making up different styling rules for the various browsers. But in some (most) cases it&#8217;s an absolute necessity. Before &#8230; ]]></description>
										<content:encoded><![CDATA[<p>First let me emphasise that I&#8217;m not a big fan of making up different styling rules for the various browsers. But in some (most) cases it&#8217;s an absolute necessity.</p>
<p>Before I continue I&#8217;d like to mention Dean Edwards <a href="http://code.google.com/p/ie7-js/" target="_blank">IE7 JavaScript library</a> which makes Microsoft Internet Explorer behave like a standards-compliant browser. It fixes many HTML and CSS issues and makes transparent PNG work correctly under IE5 and IE6. That saves you the hassle of making tons of IE specific style sheets and embedding them using these <a href="http://www.positioniseverything.net/articles/multiIE.html" target="_blank">conditional comments</a> (bottom of page).</p>
<p>So with IE out of the way there&#8217;s still a few Opera and Safari &#8220;bugs&#8221; that may need attention. Instead of relying on JavaScript, which will be ignored by some browsers or users that have disabled Java, you may try this PHP approach that I successfully implemented on one of my sites today.</p>
<p><span id="more-813"></span></p>
<p><strong>The simple approach</strong></p>
<p>Detect the Safari browser and insert your css like this:</p>
<pre>&lt;?php if (strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) : ?&gt;
    &lt;style type="text/css"&gt;
    &lt;!--
        div#safari{your-css-rules-here}
    --&gt;
    &lt;/style&gt;
&lt;?php endif; ?&gt;</pre>
<p>Detect the Opera browser and insert your css like this:</p>
<pre>&lt;?php if (strstr($_SERVER['HTTP_USER_AGENT'], 'Opera')) : ?&gt;
&lt;style type="text/css"&gt;
    &lt;!--
        div#opera{your-css-rules-here}
    --&gt;
&lt;/style&gt;
&lt;?php endif; ?&gt;</pre>
<p>Couldn&#8217;t be any easier than that could it <img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> You may off course link to an external style sheet as well if you like. The above is just meant to illustrate the method. If you got an even easier way please feel free to share!</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">813</post-id>	</item>
	</channel>
</rss>
