palindromo - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of palindromo.php

  1. <?php
  2. $a="anna";
  3. $b= str_split($a);
  4.  
  5. for($i=0;$i<count($b);$i++)
  6.   print $b[$i];
  7. print"\r\n";
  8. $verifica=true;
  9. for($i=0;$i<count($a);$i++)
  10.   if($b[i]==$b[count($b)-1-$i])
  11.     $verifica=$verifica&&($b[$i]==$b[count($b)-1-$i]);
  12.   if($verifica)
  13.     print"l'input è un palindromo";
  14.   else
  15.     print"l'input non è un palindromo";
  16.   
  17. ?>
  18.  
File Description
  • palindromo
  • PHP Code
  • 18 Jan-2022
  • 332 Bytes
You can Share it: