Skip to content

Instantly share code, notes, and snippets.

@MZAWeb
Created Aug 26, 2012
Embed
What would you like to do?
array_intersect_assoc
<?php
function my_array_compare( $val1, $val2 ) {
return ( $val1["parent_entry_id"] == $val2["parent_entry_id"] );
}
$first = array( array( "parent_entry_id" => 123 ), array( "parent_entry_id" => 987 ), );
$second = array( array( "parent_entry_id" => 123 ),
array( "parent_entry_id" => 321 ),
array( "parent_entry_id" => 789 ),
array( "parent_entry_id" => 987 ), );
$third = array_uintersect( $first, $second, 'my_array_compare' );
var_dump( $third );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment