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.
<?php
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);
return $data;
}
echo rainbow('this is a test with [rainbow]rainbow colors[/rainbow] and more text');
?>

Comment