note 39505 added to function.explode

From: Date: Fri, 30 Jan 2004 19:36:43 +0000
Subject: note 39505 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-64453@lists.php.net to get a copy of this message
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";} ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39505 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39505&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39505&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64453) next »