我有一个 php 脚本,它输出一个 json 响应,看起来像这样(如果重要,下面的响应是由测试 ajax 调用输出的)---
{
"type": "the type",
"typesm": "type of",
"entries": [
{
"title": "title one",
"body": "Original text",
"image": "image 1 url",
"time": "1558532690",
"meta": {
"mainColor": "#100a0e",
"adSpace": null
}
},
{
"title": "title two",
"body": "Original text",
"image": "image 1 url",
"time": "1558515409",
"meta": {
"mainColor": "#100a0e",
"adSpace": null
}
},
所以在我的entries我有重复的值bodyand image,但其他一切似乎都很好。
例如,在我的脚本中,我像这样输出我的值 -
$entries = $result->entries;
foreach ($entries as $ent){
echo $ent->image;
echo $ent->title;
echo $ent->body;
}
我的问题是我不想输出任何带有重复数据的条目,无论标题是否不同。如果图像和正文作为另一个条目重复,那么我想跳过它。
我怎样才能做到这一点?