gpt4 book ai didi

PHP 数组按值排序

转载 作者:可可西里 更新时间:2023-11-01 01:14:35 24 4
gpt4 key购买 nike

<分区>

我已经更新了我的问题,请检查。

我有一个如下所示的数组:

$array = [
0 => [
"term" => "DECATHLON",
"count" => 7,
],
1 => [
"term" => "babywalz",
"count" => 6,
],
2 => [
"term" => "Douglas",
"count" => 3,
],
3 => [
"term" => "NETFLIX",
"count" => 2,
],
4 => [
"term" => "zalando",
"count" => 2,
],
5 => [
"term" => "Ernsting's family",
"count" => 1,
],
6 => [
"term" => "Spotify",
"count" => 1,
],
7 => [
"term" => "eventim",
"count" => 1,
]
];

我想像这样对数组进行排序:

$array = [
1 => [
"term" => "babywalz",
"count" => 6,
],
0 => [
"term" => "DECATHLON",
"count" => 7,
],
2 => [
"term" => "Douglas",
"count" => 3,
],
5 => [
"term" => "Ernsting's family",
"count" => 1,
],
7 => [
"term" => "eventim",
"count" => 1,
],
3 => [
"term" => "NETFLIX",
"count" => 2,
],
6 => [
"term" => "Spotify",
"count" => 1,
],
];

任何建议都会有所帮助。我已经使用了 asort(),但它并没有像我想要的那样工作。我也尝试过使用 natcasesort()。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com