Generate Rainbow Text

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    The function is unusable in that way, its so much logical to write an array... It can be used for some ad links for example, or one line of text, but for storing a post in db nope.


    • #17
      the 2nd post i wrote works perfectly in my site as a function and in bbcode function


      • #18
        the above code snippet was just an example of how you could use without an array.
        i didnt realise i would have to go as far as writing this next function to add a bbcode parser etc.
        thought you guys may see the potential in the snippet and add as necessary.

        PHP Code:
        function rainbow($data) {
        $data preg_replace_callback('/\[rainbow\](.*?)\[\/rainbow\]/msi'create_function('$matches''{
        $rainbow = \'\'; 
        for($i=0; $i<strlen($matches[1]); ++$i){ 
        $letter = str_split($matches[1]); 
        if($letter[$i] != \' \'){ 
        $rainbow .= \'<span style="color:#\'.substr(str_shuffle(\'ABCDEF0123456789\'), 0, 6).\';">\'.$letter[$i].\'</span>\'; 
        } else {  
        $rainbow .= \' \';  

        return $rainbow;
        ) , $data);

        rainbow('this is a test with [rainbow]rainbow colors[/rainbow] and more text'); 
        and although it may not be logical to save long strings of html to a database.
        thats not to say it can't be done.

        truely i dont see any issues with the color randomly changing on a new page refresh anyway.
        and from what i can see from other posts all the functions would randomly change the color anyhow.
        Last edited by Ghost; 22.02.14, 17:34.