<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>Comments on: Powerful PHP: Less Known String Manipulation</title>
	<atom:link href="/2011/08/18/powerful-php-less-known-string-manipulation/feed/" rel="self" type="application/rss+xml" />
	<link>/2011/08/18/powerful-php-less-known-string-manipulation/</link>
	<description>on web development</description>
	<lastBuildDate>Fri, 26 Oct 2018 21:40:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>By: Gary Hvizdak</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-19220</link>
		<dc:creator><![CDATA[Gary Hvizdak]]></dc:creator>
		<pubDate>Sat, 24 Aug 2013 13:19:23 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-19220</guid>
		<description><![CDATA[Tom says:	
August 18, 2011 at 5:06 pm	

Also, when checking if a string is longer then, let’s say 32 characters, if($str[33]) is faster then if (strlen($str) &#062; 32)!

Yikes!  This isn&#039;t binary safe!  What if the 33 byte is a binary zero?]]></description>
		<content:encoded><![CDATA[<p>Tom says:<br />
August 18, 2011 at 5:06 pm	</p>
<p>Also, when checking if a string is longer then, let’s say 32 characters, if($str[33]) is faster then if (strlen($str) &gt; 32)!</p>
<p>Yikes!  This isn&#8217;t binary safe!  What if the 33 byte is a binary zero?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-15419</link>
		<dc:creator><![CDATA[Steve]]></dc:creator>
		<pubDate>Sat, 07 Apr 2012 03:26:46 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-15419</guid>
		<description><![CDATA[substr($s, 0, 1) and $s[0] give you the first byte, which may not be a complete character. $s = &quot;ɥello&quot;;]]></description>
		<content:encoded><![CDATA[<p>substr($s, 0, 1) and $s[0] give you the first byte, which may not be a complete character. $s = &#8220;ɥello&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim O'Halloran</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-14415</link>
		<dc:creator><![CDATA[Jim O'Halloran]]></dc:creator>
		<pubDate>Tue, 23 Aug 2011 23:52:07 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-14415</guid>
		<description><![CDATA[@Tom - The @ (error suppression) operator has some performance overhead, even more so if it actually needs to suppress an error.  See http://seanmonstar.com/post/909029460/php-error-suppression-performance for more info.]]></description>
		<content:encoded><![CDATA[<p>@Tom &#8211; The @ (error suppression) operator has some performance overhead, even more so if it actually needs to suppress an error.  See <a href="http://seanmonstar.com/post/909029460/php-error-suppression-performance" rel="nofollow">http://seanmonstar.com/post/909029460/php-error-suppression-performance</a> for more info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-14410</link>
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Fri, 19 Aug 2011 07:13:54 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-14410</guid>
		<description><![CDATA[@Jason Ok, I double checked it it just to be sure. I found some interesting things actually.

The $str[33] method is faster. But, as you mentioned, It&#039;ll give you a notice if the string is shorter. So you want to put a @ in front of it to ignore that notice.. But this actually makes it slower for some reason! Even if you don&#039;t produce an error!

My test:
String: &#039;abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz&#039;;
length: 52


 strlen(): 0.784919977188...
 []      : 0.502612113953...
@[]      : 1.37400698662...!!
 {}      : 0.206066131592...
]]></description>
		<content:encoded><![CDATA[<p>@Jason Ok, I double checked it it just to be sure. I found some interesting things actually.</p>
<p>The $str[33] method is faster. But, as you mentioned, It&#8217;ll give you a notice if the string is shorter. So you want to put a @ in front of it to ignore that notice.. But this actually makes it slower for some reason! Even if you don&#8217;t produce an error!</p>
<p>My test:<br />
String: &#8216;abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz&#8217;;<br />
length: 52</p>
<p> strlen(): 0.784919977188&#8230;<br />
 []      : 0.502612113953&#8230;<br />
@[]      : 1.37400698662&#8230;!!<br />
 {}      : 0.206066131592&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-14409</link>
		<dc:creator><![CDATA[Jason]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 22:42:54 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-14409</guid>
		<description><![CDATA[That will also throw a warning if the key does not exist. 

if(array_key_exists(33, (array)$string)){ ... } 

I&#039;m not convinced that if($string[33]) ... is faster than if(strlen($string) &#062; 32) { ... }]]></description>
		<content:encoded><![CDATA[<p>That will also throw a warning if the key does not exist. </p>
<p>if(array_key_exists(33, (array)$string)){ &#8230; } </p>
<p>I&#8217;m not convinced that if($string[33]) &#8230; is faster than if(strlen($string) &gt; 32) { &#8230; }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stoimen</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-14408</link>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 14:08:04 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-14408</guid>
		<description><![CDATA[@Tom - Great! Thanks!]]></description>
		<content:encoded><![CDATA[<p>@Tom &#8211; Great! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>/2011/08/18/powerful-php-less-known-string-manipulation/comment-page-1/#comment-14407</link>
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 14:06:44 +0000</pubDate>
		<guid isPermaLink="false">/?p=2343#comment-14407</guid>
		<description><![CDATA[You can also do this with de []&#039;s, like: $str[0];

Also, when checking if a string is longer then, let&#039;s say 32 characters, if($str[33]) is faster then if (strlen($str) &#062; 32)!]]></description>
		<content:encoded><![CDATA[<p>You can also do this with de []&#8217;s, like: $str[0];</p>
<p>Also, when checking if a string is longer then, let&#8217;s say 32 characters, if($str[33]) is faster then if (strlen($str) &gt; 32)!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
