$array1= array( array( 'StudentId' => 1 ),array( 'StudentId' => 2 ) ) ;
$array2= array (array ( 'StudentId' => 1 )) ;
I need to get difference between $array1 & $array2 and output must be as follow.
Array ( [0] => Array ( [StudentId] => 2 ) )
$array1= array( array( 'StudentId' => 1 ),array( 'StudentId' => 2 ) ) ;
$array2= array (array ( 'StudentId' => 1 )) ;
I need to get difference between $array1 & $array2 and output must be as follow.
Array ( [0] => Array ( [StudentId] => 2 ) )
I solved this as following,
$array1 = array( array( 'StudentId' => 1 ), array( 'StudentId' => 2 ) );
$array2 = array( array( 'StudentId' => 1 ));
foreach($array1 as $a=>$val){
if(in_array($val,$array2)){
unset($array1[$a]);
}
}
var_dump(array_values($array1));