note 75358 deleted from function.explode by tularis

From: Date: Mon, 27 Oct 2008 13:05:44 +0000
Subject: note 75358 deleted from function.explode by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145819@lists.php.net to get a copy of this message
Note Submitter: tobylewis at logogriph dot com ---- Watch out for this gottcha. Consider: $arr = explode("/", ""); This should return a null array (ie count($arr) == 0). Array ( ) However, explode will instead return an array of one item which is a null string. Array ( [0] => ) There is some logic to the way this works but consider the following: $addressees = "email@domain1.com, email@domain2.com"; $arr = explode(",", $addressees); foreach($arr AS $to) mail ($to, $subject, $message); with two items in the list it would sent two separate emails, with one it would sent one email message but with $addressees = "" it will still attempt to send one message that will fail because instead of returning an empty array explode returns an array with an empty item.

« previous php.notes (#145819) next »