Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $text = $_GET['text'];
- $minFontSize = (int)$_GET['minFontSize'];
- $maxFontSize = (int)$_GET['maxFontSize'];
- $step = (int)$_GET['step'];
- $fontSize = $minFontSize;
- $fontOperation = 'increment';
- for ($i=0; $i < strlen($text); $i++) {
- $nextChar = $text[$i];
- $asciiCode = ord($nextChar);
- $isLetter = ($asciiCode > 64 && $asciiCode < 91) || ($asciiCode > 96 && $asciiCode < 123);
- $output = "<span style='font-size:{$fontSize};";
- if ($asciiCode % 2 == 0) {
- $output .= 'text-decoration:line-through;';
- }
- echo $output."'>".htmlspecialchars($nextChar).'</span>';
- if ($isLetter) {
- if ($fontOperation == 'increment' && $fontSize < $maxFontSize) {
- $fontSize += $step;
- } elseif ($fontOperation == 'increment' && $fontSize >= $maxFontSize) {
- $fontSize -= $step;
- $fontOperation = 'decrement';
- } elseif ($fontOperation == 'decrement' && $fontSize > $minFontSize) {
- $fontSize -= $step;
- } elseif ($fontOperation == 'decrement' && $fontSize <= $minFontSize) {
- $fontSize += $step;
- $fontOperation = 'increment';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement