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

    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


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


Edited by phphp


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.

Edited by phphp

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.