On 8 Aug 2011, at 21:41, Andre Polykanine wrote:

> DPB> does it return the number of characters within a string --- instead,
> DPB> as you likely know, you'd use strlen().
> 
>      For sure. But I'm asking: why it doesn't return 0 if it is not an array? 
> Logically: no array - no items!


The manual explains what the function does - you may want to check it out cos 
it does the same for all the other functions too.

"Returns the number of elements in var. If var is not an array or an object 
with implemented Countable interface, 1 will be returned. There is one 
exception, if var is NULL, 0 will be returned."

IOW, if you pass it a variable, that has one element, so it returns 1. An array 
may have 0 to many elements, and null, logically, has none. Rocket science this 
ain't!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to