Quickly find multiple left rotations of an array | Set 1 | Function to left rotate an array k times ; Print array after k rotations ; Driver program
< ? php function leftRotate ( $ arr , $ n , $ k ) { for ( $ i = $ k ; $ i < $ k + $ n ; $ i ++ ) echo $ arr [ $ i % $ n ] , " ▁ " ; } $ arr = array ( 1 , 3 , 5 , 7 , 9 ) ; $ n = sizeof ( $ arr ) ; $ k = 2 ; leftRotate ( $ arr , $ n , $ k ) ; echo " STRNEWLINE " ; $ k = 3 ; leftRotate ( $ arr , $ n , $ k ) ; echo " STRNEWLINE " ; $ k = 4 ; leftRotate ( $ arr , $ n , $ k ) ; echo " STRNEWLINE " ; ? >