note 63826 added to function.unset
| From: | jarrod at osu1 dot php dot net | Date: | Sat, 01 Apr 2006 00:39:39 +0000 |
| Subject: | note 63826 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107110@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 81.223.254.68
Probable Submitter: 212.76.33.89 (proxied: 82.210.159.166)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- http://master.php.net/note/edit/63826
Del: integrated -- http://master.php.net/note/delete/63826/integrated
Del: useless -- http://master.php.net/note/delete/63826/useless
Del: bad code -- http://master.php.net/note/delete/63826/bad+code
Del: spam -- http://master.php.net/note/delete/63826/spam
Del: non-english -- http://master.php.net/note/delete/63826/non-english
Del: in docs -- http://master.php.net/note/delete/63826/in+docs
Del: other reasons-- http://master.php.net/note/delete/63826
Reject -- http://master.php.net/note/reject/63826
Search -- http://master.php.net/manage/user-notes.php