PHP compare two objects with same properties but different properties values, get non-matching values -


i have these 2 objects contained in array:

array (size=2)  0 =>  object(stdclass)[20]   public 'name' => string 'john' (length=4)   public 'surname' => string 'd' (length=1)   public 'id_number' => string '924' (length=3)   public 'file' => string '1001' (length=4)   public 'arrival_date' => string '1368466111' (length=10) 1 =>  object(stdclass)[21]   public 'name' => string 'john' (length=4)   public 'surname' => string 'd' (length=1)   public 'id_number' => string '924' (length=3)   public 'file' => string '1002' (length=4)   public 'arrival_date' => string '1368466190' (length=10) 

it great come 3 arrays or 3 objects following:

array('name'=>'john','surname'=>'d','id_number'=>'924') - contains matching values array('file'=>'1001','arrival_date'=>'1368466111') - contains first set of different values array('file'=>'1002','arrival_date'=>'1368466190') - 2nd set of not matching values 

the story behind code upon arrival of each person, open file, , @ point in time, want each person list name , beneath name , identification (that identical each arrival) list arrival files, each in row.

what you, think? there neat way accomplish this? did far mess - tons of code poor results.

there built in functions that. need cast objects array work though (which array of public properties of object). assuming variable called $var:

$a1 = (array)$var[0]; $a2 = (array)$var[1]; $inboth       = array_intersect_assoc($a1, $a2); $onlyinfirst  = array_diff_assoc($a1, $a2); $onlyinsecond = array_diff_assoc($a2, $a1); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -