MY OWN PROPER EXPLANATION ALONG WITH FULL CONCEPTS OF STRTOLOWER() FUNCTION AND STRREV() FUNCTION AND ALSO HERE I HAVE SHOWN HOW TO CHECK WHETHER A STRING IS PALINDROME OR NOT
MY OWN PROPER EXPLANATION ALONG WITH FULL CONCEPTS OF STRTOLOWER() FUNCTION AND STRREV() FUNCTION AND ALSO HERE I HAVE SHOWN HOW TO CHECK WHETHER A STRING IS PALINDROME OR NOT
Wap check a string whether it is Palindrome or not.
e.g Madam => Madam => Palindrome.
Hi all, very good afternoon. In this blog I am going to explain about the proper concepts of strtolower() function and strrev() function along with that I will also show you how to check whether a string is palindrome or not.
But before all this, guy's first you tell me one answer of the question that what is string? Ok, np if you don't know, I am their to explain about the concept of string.
So, guy's first of all, let's discuss about the concept of string. So, string is nothing but it a unique character which is enclosed either within a single inverted comma i.e. '' or within a double interted comma i.e. "".
Now just let me discuss with you about the concept of string palindrome. So, guy's what is string palindrome?
String palindrome is nothing but a character which if I reverse that character, the character will remain the same. If you want the examples from me about string palindrome, I am ready to provide you the examples of a string palindrome. So, let's discuss with some examples of string palindrome below.
EXAMPLES OF STRING PALINDROME =>
Madam = This is a string palindrome. Because if I reverse the word Madam, after reversing the word Madam the Madam will remain the same. That's why it's a string palindrome.
Similar examples like Civic, Radar, Level, Refer, etc.
Now coming to the concept of strtolower() function.
So, guy's strtolower() function is a function which converts the uppercase letters of an alphabet into lowercase letters. Like for Madam, M is the uppercase letter, so here what will strtolower() function do? Here only the answer lies. strtolower() function will convert this capital M (M) into small m(m) which means strtolower() function converts the M from uppercase letter into m lowercase letter.
Now coming to the concept of strrev() function.
So, guy's you only tell me what do you understand by the mneaning strrev. Ok, np, if you don't know I am there to explain you.
strrev() function is the function which reverse the entire string. For example like here Madam or Civic or Radar or Level or Refer this are all string. So here what do strrev() function do. Here only strrev() function utility comes. strrev() function simply reverse this entire string. Which means strrev() function reverse the string Madam into Madam, Civic into Civic, radar into Radar, Level into Level and Refer into Refer.
So, in my code I am declaring one variable $str where I am keeping my string Madam, so simple $str="Madam". After that I am taking the same variable name $str and there I am converting the string into lowercase letters from uppercase letter using strtolower() function, so it is "$str=strtolower($str);", then I am taking another variable as $str2 which I am again converting the string into lowercase letters from uppercase letter using strtolower() function and after converting the string into lowercase letters from uppercase letter using strtolower() function I am again using strrev() function to reverse the entire string, so it is "$str2=strtolower(strrev($str));". Then I am checking if $str is equal to equal to $str2 by using if condition. And if the if condition satisfied then it will print "The string is a palindrome" otherwise it will move on to the else part and it will print "The string is not a palindrome".
CODE OF PALINDROME STRING =>
<?php
$str="Madam";
$str=strtolower($str);
$str2=strtolower(strrev($str));
if ($str==$str2) {
echo "The string is a palindrome";
}
else{
echo "The string is not a palindrome";
}
?>
OUTPUT OF CODE OF PALINDROME STRING =>
Comments
Post a Comment