Following three lines generate the next circular permutation of a number . We move last digit to first position .
$ rem = $ num % 10 ; $ div = ( int ) $ num / 10 ; $ num = ( pow ( 10 , $ count - 1 ) ) * $ rem + $ div ;