From: Kenneth D. <ke...@se...> - 2009-02-23 12:21:27
|
Arlo Leach wrote: >> "If delimiter contains a value that is not contained in string , then >> explode() will return an array containing string" >> >> So, since your string doesn't contain a "|" is returns the "array" of an >> empty string. Make sense? >> > > That does make sense -- so PHP is functioning as documented. But does this > seem like the right behavior to others? I think it would be the expected > behavior if $string is not empty, but if $string is empty, I would expect > $array to be empty, too, regardless of the delimiter. > What actually matters is what you do with it afterward. If we assume you are iterating the array, will you get undesirable affects from looping over a single empty value? If so, why? Let me ask this: if you had a string like this: "a|b||c", then explode would give 4 values and one of them would be empty. If you need a special handler for that then you've probably coded it already and your code should handle PHP's behavior just fine. If you do not need a special handler then your code will probably still run just fine. Is there some reason your downstream code will break on an array of one empty string? > Or, if this is a hopeless cause, does anyone have a better workaround than > my little conditional check? > > Thanks! > > -Arlo > > _______________________________ > > Arlo Leach > 773.769.6106 > http://arlomedia.com > > > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss > -- Kenneth Downs Secure Data Software ke...@se... www.andromeda-project.org www.secdat.com Office: 631-689-7200 Cell: 631-379-0010 Fax: 631-689-0527 |