Here's the thing:
Let's say that I'm creating a database for a football season. There are two columns: player1 and player 2, and a third one wich I will call it "flag". What I need is that if the flag is on "1", the text for the player1 change to bold and the player2 remain normal or viceversa if the flag is 2.
I know it sounds difficult, but that's the best way to put it. The real case is harder to explain.
Cheers!
Simple solution is:
$results = [
array(
'team1' => 'TEAM_1',
'team2' => 'TEAM_2',
'flag' => 0,
),
array(
'team1' => 'TEAM_1',
'team2' => 'TEAM_2',
'flag' => 1,
),
array(
'team1' => 'TEAM_1',
'team2' => 'TEAM_2',
'flag' => 2,
),
];
foreach ($results as $r) {
if ($r['flag'] == 1) {
echo '<b>' . $r['team1'] . '</b>';
} else {
echo $r['team1'];
}
echo ' vs. ';
if ($r['flag'] == 2) {
echo '<b>' . $r['team2'] . '</b>';
} else {
echo $r['team2'];
}
}