<?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>stoimen.com/blog</title>
	<atom:link href="http://www.stoimen.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stoimen.com/blog</link>
	<description>web developing</description>
	<lastBuildDate>Fri, 03 Sep 2010 09:42:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Better Way to Unset Variables in PHP</title>
		<link>http://www.stoimen.com/blog/2010/09/03/the-better-way-to-unset-variables-in-php/</link>
		<comments>http://www.stoimen.com/blog/2010/09/03/the-better-way-to-unset-variables-in-php/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 09:42:31 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Parameter]]></category>
		<category><![CDATA[php functions]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[php tricks]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Unset]]></category>
		<category><![CDATA[unset in php]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1953</guid>
		<description><![CDATA[Don&#8217;t know why, but most of times I see the PHP unset() multilined with a only one parameter!? unset&#40;$var1&#41;; unset&#40;$var2&#41;; unset&#40;$var3&#41;; But as you can see from the PHP doc page of unset() this method takes optional parameter count. void unset&#40;mixed $var &#91;, mixed $var &#91;, mixed $...&#93;&#93;&#41; So perhaps a better solution can be: [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list()'>PHP: What is More Powerful Than list()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list() &#8211; Perhaps extract()'>PHP: What is More Powerful Than list() &#8211; Perhaps extract()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/19/php-associative-arrays-coding-style/' rel='bookmark' title='Permanent Link: PHP Associative Arrays Coding Style'>PHP Associative Arrays Coding Style</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t know why, but most of times I see the PHP unset() multilined with a only one parameter!?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>But as you can see from the PHP <a title="doc page of unset()" href="http://php.net/manual/en/function.unset.php" target="_blank">doc page of unset()</a> this method takes optional parameter count.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">void <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span>mixed <span style="color: #000088;">$var</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> mixed <span style="color: #000088;">$var</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> mixed $<span style="color: #339933;">...</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>So perhaps a better solution can be:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$var2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$var3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It&#8217;s at least single lined!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list()'>PHP: What is More Powerful Than list()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list() &#8211; Perhaps extract()'>PHP: What is More Powerful Than list() &#8211; Perhaps extract()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/19/php-associative-arrays-coding-style/' rel='bookmark' title='Permanent Link: PHP Associative Arrays Coding Style'>PHP Associative Arrays Coding Style</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/09/03/the-better-way-to-unset-variables-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Friday Algorithms: Input Data and Complexity</title>
		<link>http://www.stoimen.com/blog/2010/09/03/friday-algorithms-input-data-and-complexity/</link>
		<comments>http://www.stoimen.com/blog/2010/09/03/friday-algorithms-input-data-and-complexity/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 09:32:47 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[algorithm complexity]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[Computational complexity theory]]></category>
		<category><![CDATA[Context of computational complexity]]></category>
		<category><![CDATA[In-place algorithm]]></category>
		<category><![CDATA[input data]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Sorting algorithms]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Theoretical computer science]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1955</guid>
		<description><![CDATA[Size of .. As we all know most of the cases a program execution time depends most from the input data. As I wrote in my post the degree of the input data estimates the algorithm complexity. Of course 3*n² is a bit faster than 5*n², but in general both functions are similar and have [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/07/16/friday-algorithms-a-data-structure-javascript-stack/' rel='bookmark' title='Permanent Link: Friday Algorithms: A Data Structure: JavaScript Stack'>Friday Algorithms: A Data Structure: JavaScript Stack</a></li>
<li><a href='http://www.stoimen.com/blog/2010/07/02/friday-algorithms-javascript-merge-sort/' rel='bookmark' title='Permanent Link: Friday Algorithms: JavaScript Merge Sort'>Friday Algorithms: JavaScript Merge Sort</a></li>
<li><a href='http://www.stoimen.com/blog/2010/07/09/friday-algorithms-javascript-bubble-sort/' rel='bookmark' title='Permanent Link: Friday Algorithms: JavaScript Bubble Sort'>Friday Algorithms: JavaScript Bubble Sort</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/09/input-data.jpg"><img class="aligncenter size-full wp-image-1961" title="input-data" src="http://www.stoimen.com/blog/wp-content/uploads/2010/09/input-data.jpg" alt="Size of the input data" width="430" height="137" /></a></p>
<h2>Size of ..</h2>
<p>As we all know most of the cases a program execution time depends most from the input data. As I wrote in my <a title="Algorithm complexity and estimation" href="http://www.stoimen.com/blog/2010/08/29/beginning-algorithm-complexity-and-estimation/" target="_blank">post</a> the degree of the input data estimates the algorithm complexity.</p>
<p>Of course 3*n² is a bit faster than 5*n², but in general both functions are similar and have the same complexity. In this case we tend to say that the size of the input data is n.</p>
<p>It is easy to bind this to arrays or other simple data structures. For example when sorting an array with n elements, the size of the input data is n, but sometimes there is not such an obvious relation between an algorithm and the size of the input data.</p>
<p>For instance when we&#8217;ve to search a path into a graph, than maybe the best way to describe the input data is by summing both the number of vertices and the number of edges.</p>
<h2>Conclusion</h2>
<p><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/09/think.jpg"><img class="aligncenter size-full wp-image-1963" title="Think, think, think" src="http://www.stoimen.com/blog/wp-content/uploads/2010/09/think.jpg" alt="Think, think, think" width="430" height="286" /></a></p>
<p>However this is important when dealing with algorithms, because a mistake in the estimation of the input data size will result in wrong algorithm estimation at all</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/07/16/friday-algorithms-a-data-structure-javascript-stack/' rel='bookmark' title='Permanent Link: Friday Algorithms: A Data Structure: JavaScript Stack'>Friday Algorithms: A Data Structure: JavaScript Stack</a></li>
<li><a href='http://www.stoimen.com/blog/2010/07/02/friday-algorithms-javascript-merge-sort/' rel='bookmark' title='Permanent Link: Friday Algorithms: JavaScript Merge Sort'>Friday Algorithms: JavaScript Merge Sort</a></li>
<li><a href='http://www.stoimen.com/blog/2010/07/09/friday-algorithms-javascript-bubble-sort/' rel='bookmark' title='Permanent Link: Friday Algorithms: JavaScript Bubble Sort'>Friday Algorithms: JavaScript Bubble Sort</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/09/03/friday-algorithms-input-data-and-complexity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: What is More Powerful Than list() &#8211; Perhaps extract()</title>
		<link>http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/</link>
		<comments>http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 15:49:35 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Associative array]]></category>
		<category><![CDATA[Comparison of programming languages]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Data structures]]></category>
		<category><![CDATA[Data types]]></category>
		<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1942</guid>
		<description><![CDATA[list() in PHP Recently I wrote about list() in PHP which is indeed very powerful when assigning variable values from array elements. $a = array&#40;10, array&#40;'here', 'are', 'some', 'tests'&#41;&#41;; list&#40;$count, $list&#41; = $a; Actually my example in the post was not correct, because I wrote that you can pass an associative array, but the truth [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list()'>PHP: What is More Powerful Than list()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/' rel='bookmark' title='Permanent Link: Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript'>Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript</a></li>
<li><a href='http://www.stoimen.com/blog/2010/09/03/the-better-way-to-unset-variables-in-php/' rel='bookmark' title='Permanent Link: The Better Way to Unset Variables in PHP'>The Better Way to Unset Variables in PHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>list() in PHP</h2>
<p>Recently I wrote <a title="PHP: what is more powerful than list" href="http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/" target="_blank">about list()</a> in PHP which is indeed very powerful when assigning variable values from array elements.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'here'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'are'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'some'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tests'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span><span style="color: #339933;">,</span> <span style="color: #000088;">$list</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span></pre></div></div>

<p>Actually my example in the post was not correct, because I wrote that you can pass an associative array, but the truth is that you cannot, and thus the array should be always with numeric keys. After noticing the comments of that post, and thanks to @Philip,  I searched a bit about how this problem can be overcome.</p>
<h2>There is a Solution</h2>
<p>As always PHP gives a perfect solution! You can see on the <a title="PHP: list - Manual" href="http://php.net/manual/en/function.list.php" target="_blank">list() doc page</a> that there is a function that may help you use an associative array.</p>
<h2>Extract</h2>
<p>extract() is perhaps less known than list(), but it does the right thing!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'count'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'list'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'here'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'are'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'some'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tests'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// 10</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// array('here'....</span></pre></div></div>

<p>Note that now both $count and $list are defined.</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list()'>PHP: What is More Powerful Than list()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/' rel='bookmark' title='Permanent Link: Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript'>Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript</a></li>
<li><a href='http://www.stoimen.com/blog/2010/09/03/the-better-way-to-unset-variables-in-php/' rel='bookmark' title='Permanent Link: The Better Way to Unset Variables in PHP'>The Better Way to Unset Variables in PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Beginning Algorithm Complexity and Estimation</title>
		<link>http://www.stoimen.com/blog/2010/08/29/beginning-algorithm-complexity-and-estimation/</link>
		<comments>http://www.stoimen.com/blog/2010/08/29/beginning-algorithm-complexity-and-estimation/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 11:05:47 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[Analysis of algorithms]]></category>
		<category><![CDATA[Asymptotic analysis]]></category>
		<category><![CDATA[Big O notation]]></category>
		<category><![CDATA[C syntax]]></category>
		<category><![CDATA[complexity]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Lenstra elliptic curve factorization]]></category>
		<category><![CDATA[Mathematical analysis]]></category>
		<category><![CDATA[Mathematical notation]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Negation]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Variable]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1937</guid>
		<description><![CDATA[Which is the Fastest Program? When a programmer sees a chunk of code he tends to evaluate it in a rather intuitive manner and to qualify it as &#8220;elegant&#8221; or not. This is quite easy, because it&#8217;s subjective and nobody knows what exactly elegant means. However behind this there is a powerful mathematical approach of [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/04/06/jquery-what-about-this-title/' rel='bookmark' title='Permanent Link: jQuery: what about this.title?'>jQuery: what about this.title?</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/11/quick-look-at-javascript-objects/' rel='bookmark' title='Permanent Link: Quick Look at JavaScript Objects'>Quick Look at JavaScript Objects</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/02/firebugs-console-time-accuracy/' rel='bookmark' title='Permanent Link: Firebug&#8217;s console.time() accuracy'>Firebug&#8217;s console.time() accuracy</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Which is the Fastest Program?</h2>
<p><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/08/complexity.jpg"><img src="http://www.stoimen.com/blog/wp-content/uploads/2010/08/complexity.jpg" alt="" title="circuit" width="430" height="213" class="aligncenter size-full wp-image-1949" /></a><br />
When a programmer sees a chunk of code he tends to evaluate it in a rather intuitive manner and to qualify it as &#8220;elegant&#8221; or not. This is quite easy, because it&#8217;s subjective and nobody knows what exactly elegant means. However behind this there is a powerful mathematical approach of measuring a program effectiveness.</p>
<p>It&#8217;s a pity that most of the developers still think of the big O notation as something from the university classes, but unusual in the practice and they barely use it their job. But before describing the big O notation, let me start from something really simple.</p>
<p>Let&#8217;s have the following example (note that all the examples are in PHP):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$s</span><span style="color: #339933;">++;</span>	
	<span style="color: #009900;">&#125;</span>	
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you can see there are two assignments and two nested loops. This is really a widely used example from any algorithm book.</p>
<h2>Constants, Languages, Compilers</h2>
<p>First of all the time to assign a value to a variable, to compare two values and to increment a variable is constant. It depends on the computer resources, the compiler or the language, but it&#8217;s constant on one machine if you compare two chunks of code. Now we can see that these operations take (add) constant time to the program, and we can assume this time is respectively a, b, c, d, e, f, g, h, i.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">// a</span>
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>		<span style="color: #666666; font-style: italic;">// b</span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">// c</span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">// d</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>		<span style="color: #666666; font-style: italic;">// e</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">// f</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// g</span>
<span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>		<span style="color: #666666; font-style: italic;">// h</span>
<span style="color: #000088;">$s</span><span style="color: #339933;">++;</span>		<span style="color: #666666; font-style: italic;">// i</span></pre></div></div>

<h2>What Matters?</h2>
<p>Actually the most important thing here is the value of n. By assigning greater values to n the more time will take the program to run. As we can see from the following table by multiplying the value of n by 10, the time became 100 times more.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">n		<span style="color: #990000;">time</span>
<span style="color: #cc66cc;">10</span>		<span style="color:#800080;">0.00002</span>
<span style="color: #cc66cc;">100</span>		<span style="color:#800080;">0.002</span>
<span style="color: #339933;">...</span>		<span style="color: #339933;">...</span></pre></div></div>

<p>What happens in fact is that we can sum all these values.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">a <span style="color: #339933;">+</span> b <span style="color: #339933;">+</span> c <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span>d <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span>e <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>f <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span>g <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span>h <span style="color: #339933;">+</span> n<span style="color: #339933;">*</span>i<span style="color: #009900;">&#41;</span></pre></div></div>

<p>and by substituting:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">a <span style="color: #339933;">+</span> b <span style="color: #339933;">+</span> c <span style="color: #339933;">=</span> k
d <span style="color: #339933;">+</span> e <span style="color: #339933;">+</span> n <span style="color: #339933;">=</span> l
g <span style="color: #339933;">+</span> h <span style="color: #339933;">+</span> i <span style="color: #339933;">=</span> m</pre></div></div>

<p>the result is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">m<span style="color: #339933;">*</span>n² <span style="color: #339933;">+</span> l<span style="color: #339933;">*</span>n <span style="color: #339933;">+</span> k</pre></div></div>

<h2>Conclusion</h2>
<p>Here the most important thing is the degree of n, because it can change dramatically the program time consumption depending on the n value. Thus this chunk has a quadratic complexity or O(n²).</p>
<p>Of course there are constants, but in the practice they are not so important. Take a look at these two functions:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">f <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">*</span>n²
g <span style="color: #339933;">=</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">*</span>n</pre></div></div>

<p>OK, for n = 1 the first one will be faster, but as n increments the second function becomes to be faster and faster, thus after a given value of n the second function is really the fastest!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/04/06/jquery-what-about-this-title/' rel='bookmark' title='Permanent Link: jQuery: what about this.title?'>jQuery: what about this.title?</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/11/quick-look-at-javascript-objects/' rel='bookmark' title='Permanent Link: Quick Look at JavaScript Objects'>Quick Look at JavaScript Objects</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/02/firebugs-console-time-accuracy/' rel='bookmark' title='Permanent Link: Firebug&#8217;s console.time() accuracy'>Firebug&#8217;s console.time() accuracy</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/29/beginning-algorithm-complexity-and-estimation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: What is More Powerful Than list()</title>
		<link>http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/</link>
		<comments>http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 12:18:39 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Binary search algorithm]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[C syntax]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Data types]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[search result page]]></category>
		<category><![CDATA[search results]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Type theory]]></category>
		<category><![CDATA[Variables]]></category>
		<category><![CDATA[web system]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1933</guid>
		<description><![CDATA[First of all list() is not an unknown method in the PHP community, where almost every PHP developer knows what it does. The pity is that it has, perhaps, remained useless, although there is hidden power in it! What is list()? Let&#8217;s assume you&#8217;ve two variables and one array with two elements: $arr = array&#40;1, [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list() &#8211; Perhaps extract()'>PHP: What is More Powerful Than list() &#8211; Perhaps extract()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/' rel='bookmark' title='Permanent Link: Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript'>Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/' rel='bookmark' title='Permanent Link: PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings'>PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First of all <a title="PHP list" href="http://php.net/manual/en/function.list.php" target="_blank">list()</a> is not an unknown method in the PHP community, where almost every PHP developer knows what it does. The pity is that it has, perhaps, remained useless, although there is hidden power in it!</p>
<h2>What is list()?</h2>
<p>Let&#8217;s assume you&#8217;ve two variables and one array with two elements:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// now a == 1, and b == 2</span></pre></div></div>

<p>Maybe the easiest way to assign to the first variable the value of the first element of the array, and to the second variable the value of the second element of the array is to use list():</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// again a == 1, and b == 2</span></pre></div></div>

<p>Note that you can do the same with as many variables/array elements you want.</p>
<p>The funny thing is that nobody use it, while I see at least one perfect usage. You can think of a typical admin panel of any web system. For sure any developer has programmed the typical table page containing a list of &#8220;things&#8221; and a paging to switch the result set page. It&#8217;s like the posts page from the WordPress admin panel, or a search result page in Google, where you&#8217;ve one page of results and at the bottom &#8211; a number of pages where you can go to another page of the search results.</p>
<p>What I&#8217;ve seen in almost every project is that typically the developers prefer to set the results for the page into one list returned from one method and the count of the entire result set is returned by another method.</p>
<p>Thus most of the times there are two methods, performing most commonly a database queries. Something like &#8211; getList($offset, $limit) and getCount() where the first one returns the page and the second one returns the count of the result set.</p>
<p>This will result into two methods, two calls and two lines of code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #339933;">...</span>
	<span style="color: #666666; font-style: italic;">// although the entire result set contains</span>
	<span style="color: #666666; font-style: italic;">// 5 elements by limiting it from the parameters</span>
	<span style="color: #666666; font-style: italic;">// only three are returned</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$list</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// where $list = array('title1', 'title2', 'title3');	</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #339933;">...</span>
	<span style="color: #666666; font-style: italic;">// here's returned the count</span>
	<span style="color: #666666; font-style: italic;">// of the entire result set</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// where $count = 5;	</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$list</span>  <span style="color: #339933;">=</span> getList<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> getCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>What actually you can do is to perform both queries in one method, perhaps called getItems($offset, $limit) where the returned value is an array containing both the list of results and the count:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getItems<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #339933;">...</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'list'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$list</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'count'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And finally when calling this method to list() that into the two variables &#8211; single lined.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> getItems<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/31/php-what-is-more-powerful-than-list-perhaps-extract/' rel='bookmark' title='Permanent Link: PHP: What is More Powerful Than list() &#8211; Perhaps extract()'>PHP: What is More Powerful Than list() &#8211; Perhaps extract()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/' rel='bookmark' title='Permanent Link: Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript'>Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/' rel='bookmark' title='Permanent Link: PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings'>PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/27/php-what-is-more-powerful-than-list/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaScript Flexibility &#8211; Regex match()</title>
		<link>http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/</link>
		<comments>http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 13:28:04 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JavaScript syntax]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1927</guid>
		<description><![CDATA[Today after two posts [#1, #2] in the past days here&#8217;s something that shows again the JavaScript power. This is not a complete example, but it&#8217;s good to start. var str = '/text/1/text/2/'; var a = str.match&#40;/(\d+)/gi&#41;; console.log&#40;a&#41;; in that example you&#8217;ll get an array with all the numbers in the string ["1", "2"] &#8211; [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Splitting Strings'>Flexible JavaScript &#8211; Splitting Strings</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Replace in a String'>Flexible JavaScript &#8211; Replace in a String</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/11/quick-look-at-javascript-objects/' rel='bookmark' title='Permanent Link: Quick Look at JavaScript Objects'>Quick Look at JavaScript Objects</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today after two posts [<a href="http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/" target="_blank">#1</a>, <a href="http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/" target="_blank">#2</a>] in the past days here&#8217;s something that shows again the JavaScript power. This is not a complete example, but it&#8217;s good to start.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'/text/1/text/2/'</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> str.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(\d+)/gi</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>in that example you&#8217;ll get an array with all the numbers in the string ["1", "2"] &#8211; yet another flexible js snippet!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Splitting Strings'>Flexible JavaScript &#8211; Splitting Strings</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Replace in a String'>Flexible JavaScript &#8211; Replace in a String</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/11/quick-look-at-javascript-objects/' rel='bookmark' title='Permanent Link: Quick Look at JavaScript Objects'>Quick Look at JavaScript Objects</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flexible JavaScript &#8211; Replace in a String</title>
		<link>http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/</link>
		<comments>http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 12:36:02 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JavaScript syntax]]></category>
		<category><![CDATA[Parameter]]></category>
		<category><![CDATA[Pattern matching]]></category>
		<category><![CDATA[Perl 6 rules]]></category>
		<category><![CDATA[Regular expression]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1923</guid>
		<description><![CDATA[Here&#8217;s yet another example of the JavaScript flexibility. You can simply call .replace() on every string and pass a regex as a parameter! var str = 'my simple string'; str.replace&#40;/ /g, '-'&#41;; // now 'str' will contain 'my-simple-string' Related posts:Flexible JavaScript &#8211; Splitting Strings JavaScript Flexibility &#8211; Regex match() What make JavaScript closures work?


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Splitting Strings'>Flexible JavaScript &#8211; Splitting Strings</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/' rel='bookmark' title='Permanent Link: JavaScript Flexibility &#8211; Regex match()'>JavaScript Flexibility &#8211; Regex match()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/what-make-javascript-closures-work/' rel='bookmark' title='Permanent Link: What make JavaScript closures work?'>What make JavaScript closures work?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s yet another example of the JavaScript flexibility. You can simply call .replace() on every string and pass a regex as a parameter!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'my simple string'</span><span style="color: #339933;">;</span>
str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/ /g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// now 'str' will contain 'my-simple-string'</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Splitting Strings'>Flexible JavaScript &#8211; Splitting Strings</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/' rel='bookmark' title='Permanent Link: JavaScript Flexibility &#8211; Regex match()'>JavaScript Flexibility &#8211; Regex match()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/what-make-javascript-closures-work/' rel='bookmark' title='Permanent Link: What make JavaScript closures work?'>What make JavaScript closures work?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flexible JavaScript &#8211; Splitting Strings</title>
		<link>http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/</link>
		<comments>http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 17:40:28 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Scripting languages]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1915</guid>
		<description><![CDATA[After reviewing a chunk of my code for today I continue to admire the flexibility of JavaScript. It&#8217;s really powerful. In that example you can get a string split it by a given symbol to an array and than get the Nth element of it. All this on one line! Amazing! var str = 'my-long-string'; [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Replace in a String'>Flexible JavaScript &#8211; Replace in a String</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/' rel='bookmark' title='Permanent Link: JavaScript Flexibility &#8211; Regex match()'>JavaScript Flexibility &#8211; Regex match()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization'>JavaScript Snippets: IF Statements Optimization</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>After reviewing a chunk of my code for today I continue to admire the flexibility of JavaScript. It&#8217;s really powerful. In that example you can get a string split it by a given symbol to an array and than get the Nth element of it. All this on one line! Amazing!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'my-long-string'</span><span style="color: #339933;">;</span>
str.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// will contain &quot;my&quot;</span></pre></div></div>

<p>the 1st and 2nd indexes contain respectively &#8220;long&#8221; and &#8220;string&#8221;!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/25/flexible-javascript-replace-in-a-string/' rel='bookmark' title='Permanent Link: Flexible JavaScript &#8211; Replace in a String'>Flexible JavaScript &#8211; Replace in a String</a></li>
<li><a href='http://www.stoimen.com/blog/2010/08/26/javascript-flexibility-regex-match/' rel='bookmark' title='Permanent Link: JavaScript Flexibility &#8211; Regex match()'>JavaScript Flexibility &#8211; Regex match()</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization'>JavaScript Snippets: IF Statements Optimization</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/24/flexible-javascript-splitting-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can Twitter Replace the RSS Feed Readers</title>
		<link>http://www.stoimen.com/blog/2010/08/23/can-twitter-replace-the-rss-feed-readers/</link>
		<comments>http://www.stoimen.com/blog/2010/08/23/can-twitter-replace-the-rss-feed-readers/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 18:07:19 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[favorite social site]]></category>
		<category><![CDATA[Online social networking]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1910</guid>
		<description><![CDATA[I&#8217;m sure this is not the first time you&#8217;ve been asked this question. However there&#8217;s nobody today that doesn&#8217;t wonder the answer. For me &#8211; yes, twitter can replace the RSS feed readers, and NO &#8211; feed readers are awsome! Yes First of all why do I use a feed reader? I&#8217;m simply seeing what&#8217;s [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/' rel='bookmark' title='Permanent Link: Check YouTube Video Existence with Zend_Gdata_YouTube'>Check YouTube Video Existence with Zend_Gdata_YouTube</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/28/make-your-own-link-shortener/' rel='bookmark' title='Permanent Link: Make your own link shortener'>Make your own link shortener</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/08/rss.jpg"><img class="aligncenter size-full wp-image-1919" title="rss" src="http://www.stoimen.com/blog/wp-content/uploads/2010/08/rss.jpg" alt="RSS" width="200" height="200" /></a></p>
<p>I&#8217;m sure this is not the first time you&#8217;ve been asked this question. However there&#8217;s nobody today that doesn&#8217;t wonder the answer. For me &#8211; yes, <a title="Twitter" href="http://twitter.com" target="_blank">twitter</a> can replace the RSS feed readers, and NO &#8211; feed readers are awsome!</p>
<h2>Yes</h2>
<p>First of all why do I use a feed reader? I&#8217;m simply seeing what&#8217;s in it and barely read the article from the reader, but rather I jump to the site, and what&#8217;s happening often in twitter is the same scenario, I just see what&#8217;s in the tweet and if it seems to be interesting to me I jump to the link (if there&#8217;s a link). The good thing is that the tweets are limited and I&#8217;m focused. That&#8217;s why twitter is my favorite social site. I can follow all of the interesting people I know from their blogs. So perhaps twitter is becoming more useful than the feed readers.</p>
<h2>No</h2>
<p>In other hand in twitter you&#8217;ve to stay all the day long to get all the tweets you need. The timeline is quickly changing and sometimes you get lots of &#8220;junk&#8221;. While in the feed reader you&#8217;ve all the &#8220;important&#8221; posts as an incoming mail. You cannot miss anything! That&#8217;s why I cannot forget the feed readers they are doing a great job!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/' rel='bookmark' title='Permanent Link: Check YouTube Video Existence with Zend_Gdata_YouTube'>Check YouTube Video Existence with Zend_Gdata_YouTube</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/28/make-your-own-link-shortener/' rel='bookmark' title='Permanent Link: Make your own link shortener'>Make your own link shortener</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/23/can-twitter-replace-the-rss-feed-readers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Returning JSON in a Zend Controller’s Action &#8211; Part 2</title>
		<link>http://www.stoimen.com/blog/2010/08/19/returning-json-in-a-zend-controller%e2%80%99s-action-part-2/</link>
		<comments>http://www.stoimen.com/blog/2010/08/19/returning-json-in-a-zend-controller%e2%80%99s-action-part-2/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 13:39:23 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[elegant solution]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JSON-RPC]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[Remote procedure call]]></category>
		<category><![CDATA[SOAPjr]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1916</guid>
		<description><![CDATA[In a reply from my latest post after following the comments, there is a much elegant solution to this use case. Simply by changing the output with a JSON helper. This also changes the content-type of the returned response. $data = array&#40;...&#41;; $this-&#62;_helper-&#62;json&#40;$data&#41;; Related posts:Returning JSON in a Zend Controller&#8217;s Action JSON and Zend Framework? [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/13/returning-json-in-a-zend-controllers-action/' rel='bookmark' title='Permanent Link: Returning JSON in a Zend Controller&#8217;s Action'>Returning JSON in a Zend Controller&#8217;s Action</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/10/json-and-zend-framework-zend_json/' rel='bookmark' title='Permanent Link: JSON and Zend Framework? &#8211; Zend_Json'>JSON and Zend Framework? &#8211; Zend_Json</a></li>
<li><a href='http://www.stoimen.com/blog/2009/11/03/ajax-datatypes-in-jquery-format-and-access/' rel='bookmark' title='Permanent Link: AJAX dataTypes in jQuery. Format and access.'>AJAX dataTypes in jQuery. Format and access.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In a reply from my latest post after following the comments, there is a much elegant solution to this use case. Simply by changing the output with a JSON helper. This also changes the content-type of the returned response.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">json</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/08/13/returning-json-in-a-zend-controllers-action/' rel='bookmark' title='Permanent Link: Returning JSON in a Zend Controller&#8217;s Action'>Returning JSON in a Zend Controller&#8217;s Action</a></li>
<li><a href='http://www.stoimen.com/blog/2010/06/10/json-and-zend-framework-zend_json/' rel='bookmark' title='Permanent Link: JSON and Zend Framework? &#8211; Zend_Json'>JSON and Zend Framework? &#8211; Zend_Json</a></li>
<li><a href='http://www.stoimen.com/blog/2009/11/03/ajax-datatypes-in-jquery-format-and-access/' rel='bookmark' title='Permanent Link: AJAX dataTypes in jQuery. Format and access.'>AJAX dataTypes in jQuery. Format and access.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/08/19/returning-json-in-a-zend-controller%e2%80%99s-action-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
