1 回答
TA贡献1821条经验 获得超4个赞
如果我正确阅读了您的问题,此功能应该可以完成工作。
$rideTimes = '[{
"poiNumberWinter": null,
"minAge": null,
"maxAge": null,
"minSize": 100,
"maxSize": null,
"minSizeEscort": 1,
"id": 1,
"titleImageId": 390,
"titleImageWinterId": null,
"createdAt": "2018-03-14T15:45:47.000Z",
"updatedAt": "2019-03-26T10:58:44.000Z",
"_titleWinter": null
},
{
"poiNumberWinter": null,
"minAge": null,
"maxAge": null,
"minSize": 100,
"maxSize": null,
"minSizeEscort": 1,
"id": 3,
"titleImageId": 390,
"titleImageWinterId": null,
"createdAt": "2018-03-14T15:45:47.000Z",
"updatedAt": "2019-03-26T10:58:44.000Z",
"_titleWinter": null
}]';
$metaData = '[{
"open": false,
"poiId": "1",
"closing": null,
"opening": "2019-08-15 10:00:00",
"showTimes": null,
"waitTime": null,
"updatedAt": "2019-08-15T20:12:40.000Z"
},
{
"open": false,
"poiId": "2",
"closing": null,
"opening": "2019-08-15 15:00:00",
"showTimes": null,
"waitTime": null,
"updatedAt": "2019-08-15T20:12:40.000Z"
}]';
function someFancyName($arrRideTime, $arrMetaData)
{
$hits = [];
foreach ($arrRideTime as $rTime) {
foreach ($arrMetaData as $mData) {
if ($mData['poiId'] == $rTime['id']) {
$hits[] = array_merge($rTime, $mData);
}
}
}
return $hits;
}
$arrRideTime = json_decode($rideTimes, true);
$arrMetaData = json_decode($metaData, true);
echo '<pre><code>';
var_dump(someFancyName($arrRideTime, $arrMetaData));
echo '</code></pre>';
- 1 回答
- 0 关注
- 181 浏览
添加回答
举报