【发布时间】:2015-03-23 17:30:08
【问题描述】:
嘿嘿。我正在使用
$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 等数字。我想从数组中删除这些数字。
任何帮助将不胜感激!
【问题讨论】:
-
它们被称为索引。为什么要删除它们?你不应该这样做。
-
是的,我知道这被称为索引,但我在 Angular JS 中使用这个 JSON,它给我带来了一些问题,所以我想删除这些索引。
-
如果您删除它们,那么您将如何遍历
pages结果?如果您向我们展示您用于读取 JSON 的代码,我们可能会提供更多帮助。
标签: php arrays json multidimensional-array