Venciity

coloring text

Aug 21st, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <?php
  4.     if (isset($_POST['inputText'])) {
  5.         $inputText = $_POST['inputText'];
  6.         $charsArray = str_split($inputText);
  7.         foreach ($charsArray as $char) {
  8.             if (ord($char) % 2 == 0) {
  9.                 echo "<span class='blue'>$char </span>";
  10.             }
  11.             else {
  12.                 echo "<span class='red'>$char </span>";
  13.             }
  14.         }
  15.     }
  16. ?>
  17. <head>
  18.     <meta charset="UTF-8">
  19.     <title>Coloring Texts</title>
  20.     <style>
  21.         .red {
  22.             color: red;
  23.         }
  24.         .blue {
  25.             color: blue;
  26.         }
  27.     </style>
  28. </head>
  29. <body>
  30.     <form action="" method="post">
  31.         <form action="" method="post">
  32.             <textarea name="inputText" id="input" cols="30" rows="10"></textarea>
  33.             <br/>
  34.             <input type="submit" value="Color text"/>
  35.         </form>
  36.         <br/>
  37.     </form>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment