Not sure why it does it, but doesn't seem to be a huge deal.  I'm guessing it's 
because an empty string is still a string. It's not null.

Anyway, it's documented at:

http://us3.php.net/manual/en/function.explode.php

A user writes:

"If you split an empty string, you get back a one-element array with 0 as the 
key and an empty string for the value."

-TG

= = = Original message = = =

I'm wondering why this is.

$data = "";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test,Test";
$array = explode(",",$data);
$count = count($array);
$count will = 2

Why doesn't the first one give me an answer of 0 instead of 1. I know  
I could do a IF $data ==  "[empty]" and then not count if its empty  
and just set it to 0, but am wondering if there was a better way.


-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to