note 39505 deleted from function.explode by tomsommer

From: Date: Fri, 30 Jan 2004 19:49:34 +0000
Subject: note 39505 deleted from function.explode by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64454@lists.php.net to get a copy of this message
Note Submitter: phil@infolinkelectronics.co.uk ---- If you want to test for an empty array after an explode this works well: We have a variable $place which may or may not have content $pieces = explode(" ",$place); foreach($pieces as $key => $value) {if ((is_null($value)) or ($value == "")) {unset($pieces[$key]);} } $pieces = array_values($pieces); // reindex the array print_r($pieces); // just view the array if(empty($pieces)) {echo "array was empty";} else {echo "array contained something";}

« previous php.notes (#64454) next »