How to swap array elements in php?
<p>I have an array</p>

<pre><code>           Array
                (
                    [0] =&gt; Array
                        (                                
                            [order_id] =&gt; 1318
                            [code] =&gt; shipping
                            [title] =&gt; UK Shipping  (Weight: 0.00kg)
                            [value] =&gt; 10.2000                                
                        )

                    [1] =&gt; Array
                        (

                            [order_id] =&gt; 1318
                            [code] =&gt; sub_total
                            [title] =&gt; Sub-Total
                            [value] =&gt; 4.7000                                
                        )

                    [2] =&gt; Array
                        (                                
                            [order_id] =&gt; 1318
                            [code] =&gt; coupon
                            [title] =&gt; Coupon (10P)
                            [value] =&gt; -0.4700                                
                        )

                    [3] =&gt; Array
                        (                                
                            [order_id] =&gt; 1318
                            [code] =&gt; tax
                            [title] =&gt; VAT (20%)
                            [value] =&gt; 2.8860
                            [sort_order] =&gt; 8
                        )

                    [4] =&gt; Array
                        (                                
                            [order_id] =&gt; 1318
                            [code] =&gt; total
                            [title] =&gt; Total
                            [value] =&gt; 17.3160                                
                        )
                    )
</code></pre>

<p>I want to swap the array index.
I want to swap the array index when [code] => coupon to [code] => sub_total, If coupon is available.
I want the position of coupon to above the subtotal.
I want the position of sub_total to above the vat.
How is it possible?
Please help me.</p>