多维数组中唯一的PHP问题

时间:2015-03-23 17:30:09

标签: php arrays json multidimensional-array

的Helle。我正在使用

$manual['pages'] = array_map("unserialize", array_unique(array_map("serialize", $manual['pages'])));

并且它在制作独特之后给我输出

{
"items": [
    {
        "manuals": [],
        "versions": [],
        "pages": {
            "0": {
                "id": "25",
                "short_title": "Windows 7 Software",
                "full_title": "Windows 7 Software",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "1": {
                "id": "26",
                "short_title": "Software: The New Paint",
                "full_title": "Software: The New Paint",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "2": {
                "id": "27",
                "short_title": "Software: The New Wordpad",
                "full_title": "Software: The New Wordpad",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "3": {
                "id": "28",
                "short_title": "Software: The New Calculator",
                "full_title": "Software: The New Calculator",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "4": {
                "id": "29",
                "short_title": "Software: The New Word",
                "full_title": "Software: The New Word",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "5": {
                "id": "30",
                "short_title": "Software: Windows Media Player 12",
                "full_title": "Software: Windows Media Player 12",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": [
                    {
                        "name": "Software"
                    }
                ]
            },
            "7": {
                "id": "11",
                "short_title": "Software Compatibility",
                "full_title": "Software Compatibility",
                "image": "http://marksmith.biz/media/7.jpg",
                "tags": []
            }
        },
        "faqs": []
    }
],
"success": "true"

}

现在我的问题是你可以看到pages数组。你可以找到像0,1,2,3等数字。我想从数组中删除这些数字。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

我找到了答案。只需使用array_values()并将其从输出中删除!