我有两个数组,看起来像这样:
array(1) {
["x8hQz"]=>
array(1) {
["2014-07-16"]=>
array(20) {
[0]=>
array(2) {
["latitude"]=>
string(16) "39.9298775948310"
["longitude"]=>
string(17) "-87.3510829502270"
}
[1]=>
array(2) {
["latitude"]=>
string(16) "39.9298960856350"
["longitude"]=>
string(17) "-87.3511097005120"
}...
所以每个数组包含一个设备ID、日期列表以及每个日期的GPS位置列表。每天可能有不同数量的GPS位置。数组是相同的,我想将数组与自身进行比较,并根据它们在数组中匹配程度删除某些日期/GPS位置组,以便当我完成后,其中一个数组只包含每个设备的独特位置列表的日子。我想比较数组中的日期,如果一天内的每个值对基于GPS位置在x英尺范围内,则丢弃匹配天的数据。
我计划通过foreach遍历两个数组,但现在我只有一个键值对来比较所有其他键值对的一个日期,因此我无法将整天与另一个数组中的日期列表进行比较。
foreach ($trackArray as $deviceKey => $deviceValue)
{
//echo $deviceKey . $deviceValue . "\n";
foreach ($deviceValue as $dateKey => $dateValue)
{
//echo $dateKey . $dateValue . "\n";
foreach ($dateValue as $locationKey => $locationValue)
{
//echo $locationKey . $locationValue . "\n";
//echo $trackArray[$deviceKey][$dateKey][$locationKey]['latitude'];
foreach ($finalTrackArray[$deviceKey] as $finalDateKey => $finalDateValue)
{
//echo $finalDateKey . $finalDateValue . "\n";
...
}
}
}
}