Skip to content

Instantly share code, notes, and snippets.

@themasch
Created April 1, 2013 18:13
Show Gist options
  • Select an option

  • Save themasch/5286609 to your computer and use it in GitHub Desktop.

Select an option

Save themasch/5286609 to your computer and use it in GitHub Desktop.
<?php
$array_a = [ 'a' => 'red', '42', true];
$array_b = [ 'blue', 42, 'true'];
var_dump(array_intersect($array_a, $array_b)); // [ '42' ]
var_dump(array_filter($array_a, function($v) use ($array_b) {
return(in_array($v, $array_b));
})); // [ '42', true ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment