Get from associative array only that elements which keys are specified

Posted by hsz on Stack Overflow See other posts from Stack Overflow or by hsz
Published on 2010-05-02T22:42:35Z Indexed on 2010/05/02 22:47 UTC
Read the original article Hit count: 265

Filed under:
|

Hello !

It's late and I know it is a very simple question but right now I do not have an idea and deadline is near..

I've got two arrays:

$array1 = array(
  'a' => 'asdasd',
  'b' => 'gtrgrtg',
  'c' => 'fwefwefw',
  'd' => 'trhrtgr',
);
$array2 = array(
  'b', 'c'
);

What was the name of function to get a part of assoc array by keys from the second array ?

$result = array(
  'b' => 'gtrgrtg',
  'c' => 'fwefwefw',
);

Thanks !

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays