Re: select specified elements from an array
| From: | Markus Fischer | Date: | Tue, 22 May 2001 22:14:00 +0000 |
| Subject: | Re: select specified elements from an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-53946@lists.php.net to get a copy of this message | ||
On Wed, May 23, 2001 at 12:06:42AM +0200, Gyozo Papp wrote :
> function array_part($fromarray, $keys)
> {
> foreach($fromarray as $key => $val)
> {
> if (in_array($key, $keys)
> $anotherarray[$key] = $val;
> }
> return $anotherarray;
> }
foreach( $keys as $key)
if( isset( $fromarray[ $key]))
$anotherarray[ $key] = $fromarray[ $key];
- Markus