Split the array and add the first part to the end | Set 2 | Function to reverse arr [ ] from index start to end ; Function to print an array ; Function to left rotate arr [ ] of size n by k ; Driver program to test above functions ; Function calling
< ? php function rvereseArray ( & $ arr , $ start , $ end ) { while ( $ start < $ end ) { $ temp = $ arr [ $ start ] ; $ arr [ $ start ] = $ arr [ $ end ] ; $ arr [ $ end ] = $ temp ; $ start ++ ; $ end -- ; } } function printArray ( & $ arr , $ size ) { for ( $ i = 0 ; $ i < $ size ; $ i ++ ) echo $ arr [ $ i ] . " ▁ " ; } function splitArr ( & $ arr , $ k , $ n ) { rvereseArray ( $ arr , 0 , $ n - 1 ) ; rvereseArray ( $ arr , 0 , $ n - $ k - 1 ) ; rvereseArray ( $ arr , $ n - $ k , $ n - 1 ) ; } $ arr = array ( 12 , 10 , 5 , 6 , 52 , 36 ) ; $ n = sizeof ( $ arr ) ; $ k = 2 ; splitArr ( $ arr , $ k , $ n ) ; printArray ( $ arr , $ n ) ; ? >