php method to reverse an integer: 1. Use the strval() function to convert the specified integer into a string type, the syntax is "strval (integer)"; 2. Use the strrev() function to reverse an integer string That’s it, the syntax is “strrev(integer string)”.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
How to reverse php An integer
In php, if you want to reverse an integer, you can use the strrev() function:
First convert the specified integer to String type
Then use the strrev() function to reverse the integer string
Implementation code:
<?php header("Content-type:text/html;charset=utf-8"); function reverse($num) { $str=strval($num); echo strrev($str)."<br>"; } reverse(123); reverse(234); reverse(23455); reverse(34235); reverse(43233); ?>
Description:
strval() function is used to obtain the string value of a variable.
strrev() function is used to reverse a string.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to reverse an integer in php. For more information, please follow other related articles on the PHP Chinese website!