Re: [PHP4BETA] howto remove key/value from array based on regexp

From: Date: Tue, 11 Apr 2000 15:01:13 +0000
Subject: Re: [PHP4BETA] howto remove key/value from array based on regexp
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-13382@lists.php.net to get a copy of this message
Hi Dan! On Tue, 11 Apr 2000, Dan Larsson wrote: > My aim is to remove any keys where the values contain nothing but > spaces and/or newlines from an array. > > $array[0] = '123'; > $array[1] = ' '; > $array[2] = 'abc'; > > so that the above array becomes > > $array[0] = '123'; > $array[1] = 'abc'; > > Any ideas? I was hopping one of the new arr. functions can help you. Else try smth. like: foreach ($array as $k => $v) (trim($v) == '') && unset ($array ($k)); I'm not sure unset()-ing doesn't screw up internal array pointer or something.[e.g. untested] -- teodor

« previous php.version4 (#13382) next »