ID: 25188
Updated by: [EMAIL PROTECTED]
Reported By: jari at reputation dot fi
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.3.3RC4
New Comment:
array_filter() with callback NULL will do the job.
Previous Comments:
------------------------------------------------------------------------
[2003-08-21 10:50:43] [EMAIL PROTECTED]
Wouldn't array_filter() provide what you're looking for?
J
------------------------------------------------------------------------
[2003-08-21 08:45:52] jari at reputation dot fi
Description:
------------
Removes all array elements with empty values from a given array.
Didn't manage to find command similar to this.
Reproduce code:
---------------
function array_compact($thisArray) {
for($i = 0; $i < sizeof($thisArray); $i++) {
if($thisArray[$i] != "") {
$newArray[] = $thisArray[$i];
}
}
return $newArray;
}
Expected result:
----------------
Array
(
[0] => banana
[1] =>
[2] => apple
)
->
Array
(
[0] => banana
[1] => apple
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25188&edit=1