How can you highlight a specific value in a table using PHP?

To highlight a specific value in a table using PHP, you can add a conditional statement within the loop that generates the table rows. Within this statement, you can check if the current value matches the specific value you want to highlight. If it does, you can apply a CSS style to highlight it, such as changing the background color or adding a border.

<?php
// Sample data for demonstration
$data = array(
    array('Name' => 'John', 'Age' => 25),
    array('Name' => 'Jane', 'Age' => 30),
    array('Name' => 'Alice', 'Age' => 22),
);

$highlightValue = 30; // Value to highlight

echo '<table>';
echo '<tr><th>Name</th><th>Age</th></tr>';
foreach ($data as $row) {
    echo '<tr>';
    foreach ($row as $key => $value) {
        if ($value == $highlightValue) {
            echo '<td style="background-color: yellow;">' . $value . '</td>';
        } else {
            echo '<td>' . $value . '</td>';
        }
    }
    echo '</tr>';
}
echo '</table>';
?>