On PHP 4.3.x ... (not using PHP 5)

Say I have two arrays, the first has keys 'key1' ... 'key20'.  The 
second has some other keys with different names (i.e. they do not 
overlap those in the first array).  I want to add certain elements from 
array1 to array2.  I can do it like this:

        $array2['key3'] = $array1['key3'];
        $array2['key8'] = $array1['key8'];
        $array2['key17'] = $array1['key17'];

or like this:

        $array2 += array('key3' => $array1['key3'], 'key8' => $array1['key8'],
                'key17' => $array1['key17']);

What would be nicer is something like:

        $array2 += array_select($array1, 'key3', 'key8', 'key17');

In other words ... a way to create an array that is a selected subset 
of another.

Is there a function that does this that I'm missing?  I realize I could 
write one but I was looking for something built-in.  Nothing I can see 
under array functions in the manual seems to do it.

Thanks,

--
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to