这是数组的简化版本。很容易按“id”或“created_by”对其进行排序,但我很难弄清楚如何按“元素”内的“e5e53240-1d5a-4b50-ad7d-cfa00f33badd”的值对其进行排序目的。我花了几个小时搜索其他问题试图弄清楚这一点,但没有运气。
所以这里是通过 print_r 的数组的简化版本:
[0] => stdClass Object
(
[id] => 12
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "Aeronca"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": "L-3B"
}
}
)
[1] => stdClass Object
(
[id] => 21
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "BEECHCRAFT"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": "N-35"
}
}
)
[2] => stdClass Object
(
[id] => 13
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "AEROSPORT"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": ""
}
}
)
所以基本上数组,当排序时,第一个元素应该在它现在的位置,然后是第三个元素,然后是第二个元素,所以它看起来像这样:
[0] => stdClass Object
(
[id] => 12
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "Aeronca"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": "L-3B"
}
}
)
[1] => stdClass Object
(
[id] => 13
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "AEROSPORT"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": ""
}
}
)
[2] => stdClass Object
(
[id] => 21
[created_by] => 776
[searchable] => 1
[elements] => {
"b2c4ecaa-f68f-4a5c-a551-339aa8f01421": {
},
"e5e53240-1d5a-4b50-ad7d-cfa00f33badd": {
"0": {
"value": "BEECHCRAFT"
}
},
"d7c903a8-fa15-4620-9d9b-2238cb48fd5c": {
"0": {
"value": "N-35"
}
}
)
请记住,实际的数组要复杂得多,并且在数组中包含近 1,000 个元素,因此希望我使用的任何方法都能最大限度地减少服务器上的负载。