This article mainly introduces the method of PHP to determine whether a string is a palindrome string. The example analyzes the techniques of PHP operating strings to determine palindrome. It has certain reference value. Friends who need it can refer to it
The example in this article describes how PHP determines whether a string is a palindrome string. The specific implementation method is as follows:
<?php 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); ?>
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's learning.
Related recommendations:
php analysis and manipulation of strings and generation of tag clouds
php converts arbitrary base numbers into 10 The hexadecimal method
php implements generating a tree list from the results of the database query
The above is the detailed content of PHP method to determine whether it is a palindrome string. For more information, please follow other related articles on the PHP Chinese website!