redarrow Posted March 22, 2007 Share Posted March 22, 2007 How can i get all the titles that match eachover to have set colors to the matching titles please cheers. <?php $title_blog[]="redarrow"; $message[]="hi there i am redarrow"; $title_comment[]="redarrow"; $message[]="hi there i like php"; $title_blog[]="me"; $message[]="hi there i am me"; $title_comment[]="me"; $message[]="hi there it me"; foreach($message as $m){ foreach($title_blog as $t_b){ foreach($title_comment as $t_c){ if($t_b==$t_c){ $color=array("blue","pink","green","red"); for($i=0; $i<count($color); $i++){ $x=$color[$i]; } } echo "<br> <font color='$x'> $t_c</font><br> $m <br>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/43764-match-colors-php-code-provided-help/ Share on other sites More sharing options...
wilorichie Posted March 22, 2007 Share Posted March 22, 2007 use an if statement Link to comment https://forums.phpfreaks.com/topic/43764-match-colors-php-code-provided-help/#findComment-212486 Share on other sites More sharing options...
redarrow Posted March 22, 2007 Author Share Posted March 22, 2007 i am using a if statement if the title is matched the title color is red but all of them are red i need them to have diffrent title colors for each match. In the code i have provided there are two matches but the color is red so how do i get the second match to use the color array please cheers. Link to comment https://forums.phpfreaks.com/topic/43764-match-colors-php-code-provided-help/#findComment-212493 Share on other sites More sharing options...
redarrow Posted March 22, 2007 Author Share Posted March 22, 2007 if you look at this new code your see that all the mtch titles are green so how do you get the second match a color from the array color. <?php $title_blog[]="redarrow"; $title_comment[]="redarrow"; $message[]="hi there i like php"; $title_blog[]="me"; $title_comment[]="me"; $message[]="hi there it me"; foreach($message as $m){ foreach($title_blog as $t_b){ foreach($title_comment as $t_c){ if($t_b==$t_c){ $color=array("blue","pink","green","red"); for($i=0; $i<count($color); $i++){ $x=".$color[$i]."; } echo "<br> <font color='$x'> $t_b</font><br>$m<br>"; } } } } ?> Link to comment https://forums.phpfreaks.com/topic/43764-match-colors-php-code-provided-help/#findComment-212511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.