Jump to content

match colors php code provided (help)


redarrow

Recommended Posts

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

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.

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>";

}
}
  }
    }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.