Count empty array
| From: | Kevin Murphy | Date: | Thu, 21 Dec 2006 21:31:05 +0000 |
| Subject: | Count empty array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246137@lists.php.net to get a copy of this 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