Advertisement
Guest User

01.RainbowLetters

a guest
Sep 6th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2. $text = $_GET['text'];
  3. $red = $_GET['red'];
  4. $green = $_GET['green'];
  5. $blue = $_GET['blue'];
  6. $nth = $_GET['nth'];
  7.  
  8. $hex = "#";
  9. $hex .= str_pad(dechex($red), 2, "0", STR_PAD_LEFT);
  10. $hex .= str_pad(dechex($green), 2, "0", STR_PAD_LEFT);
  11. $hex .= str_pad(dechex($blue), 2, "0", STR_PAD_LEFT);
  12. $hex = strtolower($hex);
  13.  
  14. $output = "<p>";
  15. for ($i = 0; $i < strlen($text); $i++) {
  16.     if (($i + 1) % $nth == 0) {
  17.         $output .= "<span style=\"color: $hex\">" . htmlspecialchars($text[$i]) . "</span>";
  18.     } else {
  19.         $output .= htmlspecialchars($text[$i]);
  20.     }
  21. }
  22. $output .= "</p>";
  23.  
  24. echo $output;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement