<?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: PHP &#8211; count() vs. sizeOf()</title>
	<atom:link href="http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/</link>
	<description>Development, Technology and such...</description>
	<lastBuildDate>Tue, 20 Jul 2010 08:44:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: buzzknow</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1567</link>
		<dc:creator>buzzknow</dc:creator>
		<pubDate>Mon, 12 Jul 2010 16:46:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1567</guid>
		<description>i&#039;ve read some test of both function and sizeof is the winner, but i&#039;ve forgot the source i read :(

regards</description>
		<content:encoded><![CDATA[<p>i&#8217;ve read some test of both function and sizeof is the winner, but i&#8217;ve forgot the source i read :(</p>
<p>regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1552</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 30 Apr 2010 07:13:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1552</guid>
		<description>Jelle said: 2010.02.05 23:24

@Pablo,
it doesn’t really matter whether you use an array with 1 million elements or an array with 10 elements. Since the function is called a million times, any time difference would add up and eventually show up in the results.

@sunny ghosh,
sizeof() and count() are exactly the same functions. They refer to the same piece of C code in the php source. This means that both count() and sizeof() will return the same values. So what you said about the differences between count() and sizeof() is not true. Here is some proof dumping the return values of both count() and sizeof():

Return values count() vs sizeof():
Filled array:
int(100000)
int(100000)
Empty array:
int(0)
int(0)
Non array:
int(1)
int(1)
Non existing variable:
int(0)
int(0)

As you can see, all values are the same.

Lastly @ Andreas,
You suggest to use count() instead of sizeof(), but since both functions have the same speed there is no real argument as to why using count(). count() isn’t exactly the “official name”, since both functions are aliases.

In my opinion it’s up to the programmer which function he uses. For example, someone who used C a lot would rather use sizeof() instead of count().</description>
		<content:encoded><![CDATA[<p>Jelle said: 2010.02.05 23:24</p>
<p>@Pablo,<br />
it doesn’t really matter whether you use an array with 1 million elements or an array with 10 elements. Since the function is called a million times, any time difference would add up and eventually show up in the results.</p>
<p>@sunny ghosh,<br />
sizeof() and count() are exactly the same functions. They refer to the same piece of C code in the php source. This means that both count() and sizeof() will return the same values. So what you said about the differences between count() and sizeof() is not true. Here is some proof dumping the return values of both count() and sizeof():</p>
<p>Return values count() vs sizeof():<br />
Filled array:<br />
int(100000)<br />
int(100000)<br />
Empty array:<br />
int(0)<br />
int(0)<br />
Non array:<br />
int(1)<br />
int(1)<br />
Non existing variable:<br />
int(0)<br />
int(0)</p>
<p>As you can see, all values are the same.</p>
<p>Lastly @ Andreas,<br />
You suggest to use count() instead of sizeof(), but since both functions have the same speed there is no real argument as to why using count(). count() isn’t exactly the “official name”, since both functions are aliases.</p>
<p>In my opinion it’s up to the programmer which function he uses. For example, someone who used C a lot would rather use sizeof() instead of count().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jelle</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1542</link>
		<dc:creator>Jelle</dc:creator>
		<pubDate>Fri, 05 Feb 2010 23:24:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1542</guid>
		<description>@Pablo, 
it doesn&#039;t really matter whether you use an array with 1 million elements or an array with 10 elements. Since the function is called a million times, any time difference would add up and eventually show up in the results.
 
@sunny ghosh, 
sizeof() and count() are exactly the same functions. They refer to the same piece of C code in the php source. This means that both count() and sizeof() will return the same values. So what you said about the differences between count() and sizeof() is not true. Here is some proof dumping the return values of both count() and sizeof():

Return values count() vs sizeof():
Filled array:
int(100000)
int(100000)
Empty array:
int(0)
int(0)
Non array:
int(1)
int(1)
Non existing variable:
int(0)
int(0)

As you can see, all values are the same.

Lastly @ Andreas,
You suggest to use count() instead of sizeof(), but since both functions have the same speed there is no real argument as to why using count(). count() isn&#039;t exactly the &quot;official name&quot;, since both functions are aliases.

In my opinion it&#039;s up to the programmer which function he uses. For example, someone who used C a lot would rather use sizeof() instead of count().</description>
		<content:encoded><![CDATA[<p>@Pablo,<br />
it doesn&#8217;t really matter whether you use an array with 1 million elements or an array with 10 elements. Since the function is called a million times, any time difference would add up and eventually show up in the results.</p>
<p>@sunny ghosh,<br />
sizeof() and count() are exactly the same functions. They refer to the same piece of C code in the php source. This means that both count() and sizeof() will return the same values. So what you said about the differences between count() and sizeof() is not true. Here is some proof dumping the return values of both count() and sizeof():</p>
<p>Return values count() vs sizeof():<br />
Filled array:<br />
int(100000)<br />
int(100000)<br />
Empty array:<br />
int(0)<br />
int(0)<br />
Non array:<br />
int(1)<br />
int(1)<br />
Non existing variable:<br />
int(0)<br />
int(0)</p>
<p>As you can see, all values are the same.</p>
<p>Lastly @ Andreas,<br />
You suggest to use count() instead of sizeof(), but since both functions have the same speed there is no real argument as to why using count(). count() isn&#8217;t exactly the &#8220;official name&#8221;, since both functions are aliases.</p>
<p>In my opinion it&#8217;s up to the programmer which function he uses. For example, someone who used C a lot would rather use sizeof() instead of count().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunny ghosh</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1536</link>
		<dc:creator>sunny ghosh</dc:creator>
		<pubDate>Tue, 22 Dec 2009 16:34:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1536</guid>
		<description>ya sizeof() its an alias for count(), bt the difference is dat count() provides a bit more information dan sizeof()
i)if da variable is an array,count returns da number of elements which sizeof even does.
ii)if da variable is nt an array,count returns 1 which sizeof even doesnt return. 
iii)if a variable doesnt exists,count returns 0  which sizeof even doesnt return.</description>
		<content:encoded><![CDATA[<p>ya sizeof() its an alias for count(), bt the difference is dat count() provides a bit more information dan sizeof()<br />
i)if da variable is an array,count returns da number of elements which sizeof even does.<br />
ii)if da variable is nt an array,count returns 1 which sizeof even doesnt return.<br />
iii)if a variable doesnt exists,count returns 0  which sizeof even doesnt return.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Glaser</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1530</link>
		<dc:creator>Andreas Glaser</dc:creator>
		<pubDate>Wed, 21 Oct 2009 09:31:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1530</guid>
		<description>Yeah you&#039;re right your way would be more accurate but would also end up with more or less the same result, since sizeOF is an alias :) 
Thanks for your nice reply (i will improve my little script soon).

Greetings</description>
		<content:encoded><![CDATA[<p>Yeah you&#8217;re right your way would be more accurate but would also end up with more or less the same result, since sizeOF is an alias :)<br />
Thanks for your nice reply (i will improve my little script soon).</p>
<p>Greetings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo</title>
		<link>http://www.andreas-glaser.com/2008/08/19/php-count-vs-sizeof/comment-page-1/#comment-1529</link>
		<dc:creator>Pablo</dc:creator>
		<pubDate>Tue, 20 Oct 2009 19:18:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.andreas-glaser.com/?p=65#comment-1529</guid>
		<description>I think your test is not so correct, is not the number of times you call count or sizeof, is the size of the array what has to be big. Making an array of 1M elements and testing count and sizeof is better.

Cheers,
Pablo Pazos Gutierrez
http://pablo.swp.googlepages.com/</description>
		<content:encoded><![CDATA[<p>I think your test is not so correct, is not the number of times you call count or sizeof, is the size of the array what has to be big. Making an array of 1M elements and testing count and sizeof is better.</p>
<p>Cheers,<br />
Pablo Pazos Gutierrez<br />
<a href="http://pablo.swp.googlepages.com/" rel="nofollow">http://pablo.swp.googlepages.com/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
