如何移动数组元素从关联数组在以下场景中的一个在PHP


How to shift array elements from associative array by one in following scenario in PHP?

我创建了一个名为$_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']的第一个键是[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从新的结果数组中被删除,每个数组值的位置被改变了一个。我该如何将我的$_POST数组转换为上述结果数组以最佳方式?

if (array_search('multiselect-all', $_POST['applicable_states']) === 0) 
    array_shift($_POST['applicable_states']);