PHP 关联数组排序
这是我的数组,如何按 saleref 对其进行排序?
Array
(
[xml] => Array
(
[sale] => Array
(
[0] => Array
(
[saleref] => 12345
[saleline] => 1
[product] => producta
[date] => 19/ 3/10
[manifest] => 0
[qty] => 1
[nextday] =>
[order_status] =>
)
[1] => Array
(
[saleref] => 12344
[saleline] => 1
[product] => productb
[date] => 18/ 3/10
[manifest] => 11892
[qty] => 1
[nextday] =>
[order_status] =>
)
Here's my array, how do I sort it by saleref?
Array
(
[xml] => Array
(
[sale] => Array
(
[0] => Array
(
[saleref] => 12345
[saleline] => 1
[product] => producta
[date] => 19/ 3/10
[manifest] => 0
[qty] => 1
[nextday] =>
[order_status] =>
)
[1] => Array
(
[saleref] => 12344
[saleline] => 1
[product] => productb
[date] => 18/ 3/10
[manifest] => 11892
[qty] => 1
[nextday] =>
[order_status] =>
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您需要维护索引关联,请使用
uasort()
。否则
usort()
可以工作示例代码,从手动注释中提取并进行了调整:
If you need to maintain index association use
uasort()
.Otherwise
usort()
would workExample code, lifted from manual comments and tweaked:
例如,通过使用 uasort()
示例脚本:
E.g. by using uasort()
example script: