note 63826 deleted from function.unset by bjori

From: Date: Sat, 01 Apr 2006 03:38:55 +0000
Subject: note 63826 deleted from function.unset by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107115@lists.php.net to get a copy of this message
Note Submitter: jarrod Reason: useless ---- If you want to unset all empty index on an array here is a one simple way: <?php // an array $arr = ('a','b','','d','','','g'); $x = 0; foreach ($arr as $index) { if ($index == '' || empty($index)) { unset($arr[$x]); } else { $temp[] = $arr[$x]; } $x++; } $arr = $temp; foreach ($arr as $echo) { echo $echo; } // output will be: abdg ?>

« previous php.notes (#107115) next »