我的阵列是这样的:
Array
(
[0] => Array
(
[name] => abc-def-12
[qty] => 250
[sub_qty] => 1385
[Location] => NOP01
)
[1] => Array
(
[name] => abc-def-23
[qty] => 1234
[sub_qty] => 615,
101,
432,
116
[Location] => NOP10,
NOP04,
NOP08,
NOP06
)
[2] => Array
(
[name] => abc-def-34
[qty] => 379
[sub_qty] => 62
[Location] => NOP08
)
[3] => Array
(
[name] => abc-def-45
[qty] => 425
[sub_qty] => 372,
89
[Location] => NOP07,
NOP05
)
[4] => Array
(
[name] => abc-def-56
[qty] => 0
)
[5] => Array
(
[name] => abc-def3.FMF
[qty] => 523
[sub_qty] => 240,
103,
180
[Location] => NOP06,
NOP08,
NOP11
)
)
我在abc-def3.FMF
之前abc-def-12
排序数组时遇到问题。这是在我使用:
function sortNames($a, $b){
return strcmp ($a['name'], $b['name']);
}
阻止名称排列如下:abc-def-12, abc-def-23, abc-def3.FMF, abc-def-34, abc-def-45, abc-def-56
我如何实现目标,以便数组打印如下:
Array
(
[0] => Array
(
[name] => abc-def3.FMF
[qty] => 523
[sub_qty] => 240,
103,
180
[Location] => NOP06,
NOP08,
NOP11
)
[1] => Array
(
[name] => abc-def-12
[qty] => 250
[sub_qty] => 1385
[Location] => NOP01
)
[2] => Array
(
[name] => abc-def-23
[qty] => 1234
[sub_qty] => 615,
101,
432,
116
[Location] => NOP10,
NOP04,
NOP08,
NOP06
)
[3] => Array
(
[name] => abc-def-34
[qty] => 379
[sub_qty] => 62
[Location] => NOP08
)
[4] => Array
(
[name] => abc-def-45
[qty] => 425
[sub_qty] => 372,
89
[Location] => NOP07,
NOP05
)
[5] => Array
(
[name] => abc-def-56
[qty] => 0
)
)