我将这两个对象包含在一个数组中:
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)
想出 3 个数组或 3 个对象,如下所示:
array('name'=>'John','surname'=>'D','id_number'=>'924') - contains the matching values
array('file'=>'1001','arrival_date'=>'1368466111') - contains the first set of different values
array('file'=>'1002','arrival_date'=>'1368466190') - 2nd set of not matching values
代码背后的故事是,当每个人到达时,我打开一个文件,在某个时间点,我希望每个人列出他的姓名,并在他的姓名和身份(每次到达时都相同)下方列出他的到达档案,每一个都排成一排。
你怎么看?有什么巧妙的方法可以做到这一点吗?到目前为止,我所做的是一团糟 - 大量代码效果不佳。