Generate all rotations of a given string | Print all the rotated string . ; Generate all rotations one by one and print ; Current index in str ; Current index in temp ; Copying the second part from the point of rotation . ; Copying the first part from the point of rotation . ; Driver Code
< ? php function printRotatedString ( $ str ) { $ len = strlen ( $ str ) ; $ temp = " ▁ " ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ j = $ i ; $ k = 0 ; while ( $ j < $ len ) { $ temp [ $ k ] = $ str [ $ j ] ; $ k ++ ; $ j ++ ; } $ j = 0 ; while ( $ j < $ i ) { $ temp [ $ k ] = $ str [ $ j ] ; $ j ++ ; $ k ++ ; } echo $ temp . " STRNEWLINE " ; } } $ str = " geeks " ; printRotatedString ( $ str ) ; ? >