T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 64
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 215
  Visitor Online : 3
  Today Visit: 129
  Total Visitor : 285995
  Most Online : 41
::: Sponsored Links :::

PR 4 For This Webpage

Vinaora Logo
Home Today :

Rainbow Text

Author : fkroerank

I figured that it could be done using an array of hex codes and heres what I've come up with

PHP Example :

<?php
function rainbow($text) {
    
$colors = array('ff00ff','ff00cc','ff0099','ff0066','ff0033','ff0000','ff3300','ff6600','ff9900','ffcc00','ffff00','ccff00','99ff00','66ff00','33ff00','00ff00','00ff33','00ff66','00ff99','00ffcc','00ffff','00ccff','0099ff','0066ff','0033ff','0000ff','3300ff','6600ff','9900ff','cc00ff');
    
$i 0;
    
$textlength strlen($text);
    while(
$i<=$textlength){
        foreach(
$colors as $key=>$value){
            if (
$text[$i] != "")    echo "<font color=\"#".$value."\">".$text[$i]."</font>";
            
$i++;
        }
    }
}
?>



Usage Example:

PHP Example :

<?php 
function rainbow($text) { 
    
$colors = array('ff00ff','ff00cc','ff0099','ff0066','ff0033','ff0000','ff3300','ff6600','ff9900','ffcc00','ffff00','ccff00','99ff00','66ff00','33ff00','00ff00','00ff33','00ff66','00ff99','00ffcc','00ffff','00ccff','0099ff','0066ff','0033ff','0000ff','3300ff','6600ff','9900ff','cc00ff'); 
    
$i 0
    
$textlength strlen($text); 
    while(
$i<=$textlength){ 
        foreach(
$colors as $key=>$value){ 
            if (
$text[$i] != "")    echo "<font color=\"#".$value."\">".$text[$i]."</font>"
            
$i++; 
        } 
    } 

?> 
<html> 
<head> 
<title>Rainbow text</title> 
</head> 
<body> 
<?php  
$this_text 
"this text would become rainbow text"
rainbow($this_text); 
?> 
</body> 
</html>


Other Example
Numbers To Letters
Numeric Currency to Alpha Word Value String
Shorten Variables Longer Than $x Characters
Remove Images Using PHP From a String
String Insertion Functions
Apache-Style Event Log Function


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007