<?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>Commenti a: Very short snippet: PHP, tagliare a parole, contando i caratteri</title>
	<atom:link href="http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/</link>
	<description>Research &#38; Development  Blog</description>
	<lastBuildDate>Thu, 09 Feb 2012 11:24:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>Di: Santino Bivacqua</title>
		<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/#comment-2463</link>
		<dc:creator>Santino Bivacqua</dc:creator>
		<pubDate>Fri, 18 Sep 2009 21:49:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2465#comment-2463</guid>
		<description>&lt;b&gt;@Giovambattista Fazioli&lt;/b&gt;: 
Infatti il principio di funzionamento è molto simile :)
Ora sono tre le soluzioni da provare per verificare (in testi lunghi) quale più veloce :)</description>
		<content:encoded><![CDATA[<p><b>@Giovambattista Fazioli</b>:<br />
Infatti il principio di funzionamento è molto simile <img src='http://www.undolog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Ora sono tre le soluzioni da provare per verificare (in testi lunghi) quale più veloce <img src='http://www.undolog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Giovambattista Fazioli</title>
		<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/#comment-2462</link>
		<dc:creator>Giovambattista Fazioli</dc:creator>
		<pubDate>Fri, 18 Sep 2009 21:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2465#comment-2462</guid>
		<description>&lt;b&gt;@Santino Bivacqua&lt;/b&gt;: interessante... in giro ne ho trovato anche una variante che usa &lt;code inline=&quot;true&quot;&gt;explode()&lt;/code&gt;, in pratica, al posto del tuo &lt;code inline=&quot;true&quot;&gt;stristr()&lt;/code&gt;:
[cc_php]
function wordCut($text, $limit, $msg){
    if (strlen($text) &gt; $limit){
        $txt1 = wordwrap($text, $limit, &#039;[cut]&#039;);
        $txt2 = explode(&#039;[cut]&#039;, $txt1);
        $ourTxt = $txt2[0];
        $finalTxt = $ourTxt.$msg;
    }else{
        $finalTxt = $text;
    }
    return $finalTxt;
} 
[/cc_php]</description>
		<content:encoded><![CDATA[<p><b>@Santino Bivacqua</b>: interessante&#8230; in giro ne ho trovato anche una variante che usa <code class="codecolorer text default"><span class="text">explode()</span></code>, in pratica, al posto del tuo <code class="codecolorer text default"><span class="text">stristr()</span></code>:</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> wordCut<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$txt1</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/wordwrap"><span style="color: #990000;">wordwrap</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'[cut]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$txt2</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'[cut]'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$txt1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ourTxt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$txt2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$finalTxt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ourTxt</span><span style="color: #339933;">.</span><span style="color: #000088;">$msg</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$finalTxt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$finalTxt</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Santino Bivacqua</title>
		<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/#comment-2461</link>
		<dc:creator>Santino Bivacqua</dc:creator>
		<pubDate>Fri, 18 Sep 2009 15:43:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2465#comment-2461</guid>
		<description>Ciao io invece utilizzo da tempo questa soluzione:
[cc_php]
function getShortDescription($text, $len, $textContinue = &#039;...&#039;) {
  $text = strip_tags($text);//Elimino eventuali tag HTML
  if (strlen($text) &lt;= (int)$len) {
    return $text;
  } else {
    $text = wordwrap($text, (int)$len, &quot;___end___&quot;);
    return  substr($text, 0, -strlen(stristr($text,&quot;___end___&quot;))) . $textContinue;
  }
}
[/cc_php]
Bisognerebbe misurare il tempo impiegato da entrambi (magari con stringhe lunghissime) e capire quale soluzione sia migliore.</description>
		<content:encoded><![CDATA[<p>Ciao io invece utilizzo da tempo questa soluzione:</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> getShortDescription<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$len</span><span style="color: #339933;">,</span> <span style="color: #000088;">$textContinue</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Elimino eventuali tag HTML</span><br />
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$len</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/wordwrap"><span style="color: #990000;">wordwrap</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$len</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;___end___&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> &nbsp;<a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stristr"><span style="color: #990000;">stristr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;___end___&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$textContinue</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Bisognerebbe misurare il tempo impiegato da entrambi (magari con stringhe lunghissime) e capire quale soluzione sia migliore.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Giovambattista Fazioli</title>
		<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/#comment-2451</link>
		<dc:creator>Giovambattista Fazioli</dc:creator>
		<pubDate>Mon, 14 Sep 2009 08:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2465#comment-2451</guid>
		<description>&lt;b&gt;@Raben&lt;/b&gt;: Ecco cosa succede a fare le ore piccole :D Thanks</description>
		<content:encoded><![CDATA[<p><b>@Raben</b>: Ecco cosa succede a fare le ore piccole <img src='http://www.undolog.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Raben</title>
		<link>http://www.undolog.com/2009/09/14/very-short-snippet-php-tagliare-a-parole-contando-i-caratteri/#comment-2450</link>
		<dc:creator>Raben</dc:creator>
		<pubDate>Sun, 13 Sep 2009 14:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2465#comment-2450</guid>
		<description>Piccolo errore nel titolo &quot;contanto&quot; ;)
semre utilissimi i tuoi post! ;)</description>
		<content:encoded><![CDATA[<p>Piccolo errore nel titolo &#8220;contanto&#8221; <img src='http://www.undolog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
semre utilissimi i tuoi post! <img src='http://www.undolog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

