Req #25188 [Com]: array_compact

From: Date: Wed, 01 Sep 2021 18:53:22 +0000
Subject: Req #25188 [Com]: array_compact
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236348@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25188&edit=1 ID: 25188 Comment by: lildurk25188 at gmail dot com Reported by: jari at reputation dot fi Summary: array_compact Status: Closed Type: Feature/Change Request Package: Feature/Change Request Operating System: All PHP Version: 4.3.3RC4 Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2004-01-10 10:07:14] andrey@php.net array_filter() with callback NULL will do the job. ------------------------------------------------------------------------ [2003-08-21 10:50:43] jay@php.net 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 https://bugs.php.net/bug.php?id=25188&edit=1

« previous php.bugs (#236348) next »