From: Arlo L. <ar...@ar...> - 2009-02-20 21:28:52
|
Hi folks, Consider the following PHP code, which explodes an empty string: $string = ""; $array = explode("|", $string); print_r($array); print "Length: ".count($array); I would expect this to output an empty array: Array ( ) Length: 0 But it actually outputs: Array ( [0] => ) Length: 1 Does anyone else find this odd? It has bitten me a few times lately, when I test the existence of data with a count(), or try to process data with a FOR loop. I end up writing this a lot to get the expected results: $array = ($string) ? explode(",", $string) : array() ; I was considering logging a bug report but wondered what your thoughts were. Cheers, -Arlo _______________________________ Arlo Leach 773.769.6106 http://arlomedia.com |