This article mainly introduces the PHP method to determine whether a string is a palindrome string, example analysis Learned the skills of PHP string manipulation to determine palindrome, which has certain reference value. Friends in need can refer to it
The example in this article describes how PHP determines whether a string is a palindrome string. Share it with everyone for your reference. The specific implementation method is as follows:
?
3 4 513 14
15
16
17
18
19
20
21
22
23
24
|
<🎜>function ishuiwen($str){<🎜> <🎜>$len=strlen($str);<🎜> <🎜>$l=1;<🎜> <🎜>$k=intval($len/2) 1;<🎜> <🎜>for($j=0;$j<$k;$j ){<🎜> <🎜>if (substr($str,$j,1)!=substr($str,$len-$j-1,1))<🎜> <🎜>{<🎜> <🎜>$l=0;<🎜> <🎜>break;<🎜> <🎜>}<🎜> <🎜>}<🎜> <🎜>if ($l==1)<🎜> <🎜>{<🎜> <🎜>return 1;<🎜> <🎜>}<🎜> <🎜>else<🎜> <🎜>{<🎜> <🎜>return -1;<🎜> <🎜>}<🎜> <🎜>}<🎜> <🎜>$str=12321;<🎜> <🎜>echo ishuiwen($str);<🎜> <🎜>?> |