Thanks you very sir #diafol,
This line work fine

    $stringOutput .= (strlen($k==4))? '<tr class='mycolor'>':'<tr>';

It changes the Background color of all rows where code lenght is 4

Is it possible to use following multiple IF ... ELSE in above format

if(strlen($k==1)){
    echo "<tr bgcolor='#ADF382'>";

} elseif (strlen($k==2)){
    echo "<tr bgcolor='#AEEE8'>";

} elseif (strlen($k==4)){
    echo "<tr bgcolor='#BE2548'>"; // YOU used this condition in $stringOutput

} else {

    echo "<tr bgcolor='#EF2548'>";
}

After applying above codes The World will look like this

Untitled.png

Where every group of code as length will be with unique background color.

Thanks

Member Avatar for diafol

Is it possible to use following multiple IF ... ELSE in above format

Did you try it? This thread is getting off point now. If you want to know how to write conditionals, that.s a separate issue. I auggest you mark this solved and start a new thread.

My dear professor #diafol,

I used these codes to fullfill the last purpose

// define the map
$bg_map = array();
$bg_map['default'] = '#E6D4ED';
$bg_map[1] = '#8CF3E7';
$bg_map[2] = '#A5EBB1';
$bg_map[4] = '#E9E999';

$stringOutput .= "<tr bgcolor='".(isset($bg_map[$mylen]) ? $bg_map[$mylen] : $bg_map['default'])."'>";  

Thanks for participating and sorting out all of the problems discussed in the thread.
May you live long.

Finally, I am closing this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.