Re: apply function to each array element?

From: Date: Mon, 29 Mar 2004 15:26:17 +0000
Subject: Re: apply function to each array element?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181668@lists.php.net to get a copy of this message
Hello raisinlove, Monday, March 29, 2004, 4:21:44 PM, you wrote: r> Hi, I'm looking for a concrete example I could use to create an array r> where each element from an original array is processed by a function. r> It seems array_walk would be the solution but it doesnt seem to output r> an array. r> My function looks up my array elements in a mysql table and outputs a r> corresponding row value. So I would like my new array to be made up of r> these values. array_walk should be fine for this, instead of creating a new array why not just modify the existing one? I.e.: function the_function (&$item) { $item = whatever_cleaning_you_need_to_do(); } array_walk($your_array_to_tidy, 'the_function'); -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#181668) next »