Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $text = $_GET['text'];
- $letterNumber = (int)$_GET['nth'];
- $colorNum = array((int)$_GET['red'], (int)$_GET['green'], (int)$_GET['blue']);
- $color = '#';
- foreach ($colorNum as $num) {
- $hex = dechex($num);
- if (strlen($hex) === 1) {
- $hex = '0' . $hex;
- }
- $color .= $hex;
- }
- $style = "style=\"color: {$color}\"";
- $result = '<p>';
- for ($i = 0; $i < strlen($text); $i++) {
- if ((($i + 1) % $letterNumber) == 0) {
- $result .= "<span {$style}>" . htmlspecialchars($text[$i]) . '</span>';
- } else {
- $result .= htmlspecialchars($text[$i]);
- }
- }
- echo $result . '</p>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement