Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8.     <head>
  9.         <meta charset="UTF-8">
  10.         <title></title>
  11.     </head>
  12.     <body>
  13.         <?php
  14.             $mot = $_POST["mot"];
  15.             $ok = true;
  16.             $i = 0;
  17.             $j = strlen($mot) - 1;
  18.            
  19.             while($i <= $j)
  20.             {
  21.                 $car1 = substr($mot, $i, 1);
  22.                 $car2 = substr($mot, $j, 1);
  23.                
  24.                 if($car1 != $car2)
  25.                 {
  26.                     $ok = false;
  27.                 }
  28.                 $i++;
  29.                 $j--;
  30.             }
  31.            
  32.             if ($ok == true)
  33.             {
  34.                 echo "Il s'agit d'un palindrome";
  35.             }
  36.            
  37.             else
  38.             {
  39.                 echo "Il ne s'agit pas d'un palindrome";
  40.             }
  41.         ?>
  42.     </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement