<?php
$rainbowmsg ="";
$var ="";
$scale="";
$out=array(' Ann',' james',' rejo mathew',' sjo d emmanual',' mary varghese','devan','benqb','riya');
$links=array(' Ann',' james',' rejo mathew',' sjo d emmanual',' mary varghese','devan','benqb','riya');
//color arrays
$rainbow = array('#C36546','#006633' , '#000099' , '#FF0000' , '#FF6699' , '#0099FF', '#FFFF00' , '#33FF00');
//get the message
for( $j=0; $j<1; $j++ )
{
foreach ($out as $value)
{
$var.= "<br/>".$value.",";
}
}
//print_r($links);
$out = $rainbow;
//split message into array
$messagearr=explode(",",trim(chunk_split($var)));
$i = 0; //$i will keep count of which color in $colorarr we're up to
$max=count($out, COUNT_RECURSIVE);
//$max = count($colorarr); //the total number of colors in $colorarr
//loop through $messagearr
foreach ($messagearr as $letter) {
//if character isn't a space, assign color and add to $rainbowmsg:
if ($letter != " ") {
{
$rainbowmsg .= "<a href=".trim($links[$i])."><font color=\"".$out[$i]."\">$letter</font></a>";
}
}
//else add a space to $rainbowmsg:
else { $rainbowmsg .= " "; }
//+1 to $i (so that the next loop uses the next color in $colorarr):
$i++;
//if we've reached the end of $colorarr, set $i to zero to start again:
if ($i == $max) { $i = 0; }
} //(end foreach loop)
//output the rainbow code:
echo "<div style='cursor:pointer'>".$rainbowmsg."</div>";
?>
When i run this code its working but when i click on "rejo mathew" the link only takes "rejo" and same as the array includes spaces in their name