使用PHP删除JSON块

使用PHP删除JSON块,php,json,Php,Json,我有两个JSON文件,与PHP脚本合并。我的PHP脚本如下所示: <?php header('Content-Type: application/json'); $a = file_get_contents("https://example.com/a.json", false); $b = file_get_contents("https://example.com/b.json", false); $merge = json_encode(array_merge( json_

我有两个JSON文件,与PHP脚本合并。我的PHP脚本如下所示:

<?php

header('Content-Type: application/json');

$a = file_get_contents("https://example.com/a.json", false);
$b = file_get_contents("https://example.com/b.json", false);

$merge = json_encode(array_merge(
  json_decode($a, true),
  json_decode($b, true)
));

echo $merge;

?>
[{
    "id": 1141,
    "iid": 167,
    "project_id": 17,
    "title": "test",
    "description": "test",
    "state": "opened",
    "created_at": "2018-02-19T13:46:38.751Z",
    "updated_at": "2018-02-19T14:32:46.061Z",
    "closed_at": null,
    "labels": [],
    "milestone": null,
    "assignees": [],
    "author": {
        "id": 19,
        "state": "active"
    },
    "assignee": null,
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "time_stats": {
        "time_estimate": 0,
        "total_time_spent": 0,
        "human_time_estimate": null,
        "human_total_time_spent": null
    }
}, {
    "id": 1140,
    "iid": 166,
    "project_id": 16,
    "title": "test2",
    "description": "test2",
    "state": "opened",
    "created_at": "2018-02-19T11:01:00.729Z",
    "updated_at": "2018-02-19T11:01:00.729Z",
    "closed_at": null,
    "labels": [],
    "milestone": null,
    "assignees": [{
        "id": 5,
        "state": "active"
    }],
    "author": {
        "id": 5,
        "state": "active"
    },
    "assignee": {
        "id": 5,
        "state": "active"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "time_stats": {
        "time_estimate": 0,
        "total_time_spent": 0,
        "human_time_estimate": null,
        "human_total_time_spent": null
    }
}, {
    "id": 1136,
    "iid": 165,
    "project_id": 17,
    "title": "test3",
    "description": "test3",
    "state": "opened",
    "created_at": "2018-02-16T15:36:22.712Z",
    "updated_at": "2018-02-16T15:36:22.712Z",
    "closed_at": null,
    "labels": [],
    "milestone": null,
    "assignees": [{
        "id": 5,
        "state": "active"
    }],
    "author": {
        "id": 1,
        "state": "active"
    },
    "assignee": {
        "id": 5,
        "state": "active"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "time_stats": {
        "time_estimate": 0,
        "total_time_spent": 0,
        "human_time_estimate": null,
        "human_total_time_spent": null
    }
}]
现在我想删除带有
“project\u id”:16的每个块。如何删除每个带有
“project\u id”:16的块

所以我想移除这个块。还有其他所有拥有
“project\u id”:16
,如果还有的话

 {
    "id": 1140,
    "iid": 166,
    "project_id": 16,
    "title": "test2",
    "description": "test2",
    "state": "opened",
    "created_at": "2018-02-19T11:01:00.729Z",
    "updated_at": "2018-02-19T11:01:00.729Z",
    "closed_at": null,
    "labels": [],
    "milestone": null,
    "assignees": [{
        "id": 5,
        "state": "active"
    }],
    "author": {
        "id": 5,
        "state": "active"
    },
    "assignee": {
        "id": 5,
        "state": "active"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "time_stats": {
        "time_estimate": 0,
        "total_time_spent": 0,
        "human_time_estimate": null,
        "human_total_time_spent": null
    }
},
非常感谢您的帮助。

这里有一个小片段

$merge = array_filter($merge, function($item){ return $item['project_id'] != 16 })