Re: does function extract() trim?

From: Date: Fri, 28 Mar 2008 21:22:25 +0000
Subject: Re: does function extract() trim?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-272261@lists.php.net to get a copy of this message
On 28 Mar 2008, at 21:14, Lamp Lists wrote:
----- Original Message ---- From: Stut <stuttle@gmail.com> To: Lamp Lists <lamp.lists@yahoo.com> Cc: php General list <php-general@lists.php.net> Sent: Friday, March 28, 2008 4:02:27 PM Subject: Re: [PHP] does function extract() trim? On 28 Mar 2008, at 20:59, Lamp Lists wrote: do not laugh, but I "discovered" today function extract(); :D before I used: foreach ($array as $key => $value) { ${$key} = trim($value); } though, "trimming" $value is kind of important to me and I would like to know if extract "trims" too? No, but you can use http://php.net/array_map to do the trim before using extract. -Stut -- http://stut.net/ function trim_array($array_element) {
    $array_element = trim($array_element);
    return $array_element;
} $myArray = array_map(trim_array, $myArray); extract($myArray); hm?!? "my way" is shorter! :D
Only if you over-complicate it. extract(array_map('trim', $myArray)); -Stut -- http://stut.net/

« previous php.general (#272261) next »