note 43614 added to function.array-splice

From: Date: Mon, 28 Jun 2004 08:15:48 +0000
Subject: note 43614 added to function.array-splice
Groups: php.notes 
Request: Send a blank email to php-notes+get-71960@lists.php.net to get a copy of this message
Also, a quick function to discard empty entries in an array which otherwise keeps keys intact: <?php function remove_empty($inarray) { if (is_array($inarray)) { foreach($inarray as $k=>$v) { if (!(empty($v))) { $out[$k]=$v; } } return $out; } else { return $inarray; } } // easy enough? print_r(remove_empty(array('', 'foo', '', 'bar', '', '', 'baz', ''))); ?> Should return: Array ( [1] => foo [3] => bar [6] => baz ) ---- Manual Page -- http://www.php.net/manual/en/function.array-splice.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43614 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43614&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43614&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71960) next »