| | |
Coloring text
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello everybody;
I want to color a text gradually by PHP
Explain: I want to color each letter with a color, like:
Hello: H=green e=red l=blue (And repeat) l=green o=red
I want to color a text gradually by PHP
Explain: I want to color each letter with a color, like:
Hello: H=green e=red l=blue (And repeat) l=green o=red
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
Surely this is a question to do with html then.
http://www.computerhope.com/htmcolor.htm
http://www.computerhope.com/htmcolor.htm
Last edited by iamthwee; Oct 13th, 2007 at 4:03 pm.
*Voted best profile in the world*
I think you did not understand me, I explain:
I wrote a chat program , I want when a user sends a message the message appears with mixed colors... the color of the first letter=green , the 2nd letter=red , the 3rd letter=blue and start over the 4th letter=green ,the 5th letter=red the 6th letter=blue and start over the 7th letter=green, 8th letter=red , 9th letter=blue .... until the message's end.
I wrote a chat program , I want when a user sends a message the message appears with mixed colors... the color of the first letter=green , the 2nd letter=red , the 3rd letter=blue and start over the 4th letter=green ,the 5th letter=red the 6th letter=blue and start over the 7th letter=green, 8th letter=red , 9th letter=blue .... until the message's end.
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
nevermind about the customizing. i made it into a function. lets say you have words contained in the variable $string, all you would have to do is call the function "color()" with the string that needs to be colored inside the parathesis ex. "color($string)" and the colored text will echoed onto the page.
Heres the color function code:
Heres the color function code:
PHP Syntax (Toggle Plain Text)
<?php function color($str) { $i = 0; while ($i < strlen($str)) { $letters[] = substr($str, $i, 1); $i++; } $colors = array(0 => '<font color="green">',1 => '<font color="red">',2 => '<font color="blue">'); $i = 0; $c = 0; while ($i < count($letters)) { if ($c == 3) { $c = 0; } echo $colors[$c] . $letters[$i] . '</font>'; $i++; $c++; } } ?>
Last edited by kkeith29; Oct 14th, 2007 at 11:42 pm.
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Questions For WebDevelopment =) (HTML and CSS)
- DreamWeaver a Tool or not? (IT Professionals' Lounge)
- Practice problem (C++)
- How to do text fade in and fade out effect (C)
- inserting coloring text (MS SQL)
- I need special stuff in my project like system("cls") (C++)
Other Threads in the PHP Forum
- Previous Thread: desperate for password protection
- Next Thread: Session variables not carrying over to next page
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary body broken cakephp checkbox class cms code cron curl database date date/time directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link list login loop mail menu mlm mod_rewrite msqli_multi_query multiple mycodeisbad mysql oop parse paypal pdf php problem query radio random recursion regex remote script search send seo server sessions sms soap source space sql static structure syntax system table tutorial update upload url validation validator variable video web webdesign wordpress xml youtube






