我有一系列日期,我想得到所有这些中的所有值,这就是我的例子:
mongoTemplate.indexOps(MyClass.class).ensureIndex(new GeospatialIndex("attribute.holding.coordinates"));
NearQuery nearQuery = NearQuery.near(x, y);
final GeoResults<MyClass> geoResults = mongoTemplate.geoNear(nearQuery, MyClass.class);
return geoResults.getContent().stream().map(GeoResult::getContent).collect(Collectors.toList());
结果:
$array = [
{"d1":["2016-01-04","2016-01-11","2016-01-18","2016-01-25","2016-02-01"]},
{"d2":["2016-01-05","2016-01-11","2016-01-19","2016-01-25","2015-12-12"]},
{"d3":["2016-01-05","2016-01-11","2016-01-25"]},
{"d4":["2016-01-04","2016-01-11","2016-01-25"]}
]
答案 0 :(得分:1)
这是一个工作示例(可以优化,但应该可以工作):
$array = json_decode('[
{"d1":["2016-01-04","2016-01-11","2016-01-18","2016-01-25","2016-02-01"]},
{"d2":["2016-01-05","2016-01-11","2016-01-19","2016-01-25","2015-12-12"]},
{"d3":["2016-01-05","2016-01-11","2016-01-25"]},
{"d4":["2016-01-04","2016-01-11","2016-01-25"]}
]');
$allArrays = array();
foreach ($array as $object) {
foreach ($object as $datesArray) {
array_push($allArrays, $datesArray);
}
}
$sharedDates = call_user_func_array('array_intersect',$allArrays);
var_dump($sharedDates);