Palindrome an other script with using functions.

Palindrome an other script with using functions. Previous Palindrome Script was coded without using any function. In this function 3 methods are used,

  1. str_split() function
  2. var_dump() function
  3. implode() function
User will input any value consist on 5 digits, then str_split() will split your word / sentence to array. And 2nd var_dump() function will show the value, type of array, then implode() function is used to combine the value. 
check this code. try it
My friend Dan Edge helped me in it.
I thank to him.


 <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">   
   <!-- to take multiple inputs copy the below line and change name="input" attribute -->   
   Enter input 1:&nbsp;<input type="text" name="input" value="" /><br />   
   <input type="submit" name="submit" value="Submit" />   
 </form>   
 <?php  
   $inputs = array();   
   if (isset($_POST['input'])) //to check if the form was submitted   
   {   
     $inputs = str_split($_POST['input']);  
     var_dump($inputs);   
     if (count($inputs) == 5)   
     {      
       if(($inputs[0]==$inputs[4])&&($inputs[1]==$inputs[3]))   
       {   
         echo implode($inputs) . ' is a palindrome number. <br />';   
       }   
       else  
       {   
         echo implode($inputs) . ' is not a palindrome number. <br />';   
       }                       
     }                
     else   
     {   
       echo "Try Again : Enter 5 Digit Number. :(";   
     }   
   }   
 ?>  

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.


Thanks for visiting Samee Articles.

========================================

Best Regards,

Samee U. Feroz

 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger