For example, there is a variable ($wo_list) whose value is the following array, and then the key value in the array is used woId
as the outermost key.
Array
(
[0] => Array
(
[woId] => 28310
[wo_name] => [2021-03-02]例行-814003 鸿大食品-老鼠-20211130
[executing_datetime] => 2021-03-02 09:29:37
[admin_ids] => 179
)
[1] => Array
(
[woId] => 27312
[wo_name] => [2021-03-31]例行-545010 阿宝北环-老鼠
[executing_datetime] => 2021-03-02 09:36:27
[admin_ids] => 123
)
[2] => Array
(
[woId] => 28374
[wo_name] => [2021-03-02]例行-804031 老四川高雄南屏店
[executing_datetime] => 2021-03-02 09:41:05
[admin_ids] => 163
)
[3] => Array
(
[woId] => 28318
[wo_name] => [2021-03-02]例行-731001 广吉后壁厂-环境虫鼠
[executing_datetime] => 2021-03-02 09:44:21
[admin_ids] => 299
)
)
1. You can use the foreach() loop function
foreach ($wo_list as $k => $v) {
$wo_list[$v['woId']] = $v;
unset($wo_list[$k]);
}
2. You can use PHP’s built-in functions
$wo_list = array_column($wo_list,null,'woId');