我关注的关联数组标题$_POST
如下:
Array
(
[op] => add
[product_id] => 12
[pack] => Array
(
[1] => 1
)
[applicable_states] => Array
(
[0] => multiselect-all
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 8
[9] => 9
[10] => 10
)
[total_count] => 3000
)
现在您可以观察数组中的第一个键$_POST['applicable_states']
it's [0] => multiselect-all
。我必须在操作数组之前检查这个键。每当此键出现在数组中时,我都需要如下$_POST
数组:
Array
(
[op] => add
[product_id] => 12
[pack] => Array
(
[1] => 1
)
[applicable_states] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
)
[total_count] => 3000
)
现在您可以从上面的数组中看到 已从[0] => multiselect-all
新的结果数组中删除,并且每个数组值都将其位置更改为 1。我应该如何以最佳方式将我的$_POST
数组转换为上述结果数组?提前致谢。