Given an integer number and we have to find, print its reverse number using PHP.
Example
Input number is: 12345
Reverse number will be: 54321
Logic
- Take (input or assign) a number
- Assign 0 to the variable, in which we are going to store reverse number (Here, I am using ‘reverse’)
- Run the following two steps until number is not zero
- Get the digit using modules (%) operator and add it into the ‘reverse*10’
- Now, divide the number by 10
- Finally, when number will be zero, print the ‘reverse’
PHP code to reverse an integer number
Output

need an explanation for this answer? contact us directly to get an explanation for this answer