Advertisement
dimipan80

Drop It

Apr 28th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2. $text = $_GET['text'];
  3. $minFontSize = (int)$_GET['minFontSize'];
  4. $maxFontSize = (int)$_GET['maxFontSize'];
  5. $step = (int)$_GET['step'];
  6.  
  7. $fontSize = $minFontSize;
  8. $fontOperation = 'increment';
  9. for ($i=0; $i < strlen($text); $i++) {
  10.     $nextChar = $text[$i];
  11.     $asciiCode = ord($nextChar);
  12.     $isLetter = ($asciiCode > 64 && $asciiCode < 91) || ($asciiCode > 96 && $asciiCode < 123);
  13.     $output = "<span style='font-size:{$fontSize};";
  14.     if ($asciiCode % 2 == 0) {
  15.         $output .= 'text-decoration:line-through;';
  16.     }
  17.  
  18.     echo $output."'>".htmlspecialchars($nextChar).'</span>';
  19.     if ($isLetter) {
  20.         if ($fontOperation == 'increment' && $fontSize < $maxFontSize) {
  21.             $fontSize += $step;
  22.         } elseif ($fontOperation == 'increment' && $fontSize >= $maxFontSize) {
  23.             $fontSize -= $step;
  24.             $fontOperation = 'decrement';
  25.         } elseif ($fontOperation == 'decrement' && $fontSize > $minFontSize) {
  26.             $fontSize -= $step;
  27.         } elseif ($fontOperation == 'decrement' && $fontSize <= $minFontSize) {
  28.             $fontSize += $step;
  29.             $fontOperation = 'increment';
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement