// Iterate through all items in array.
foreach ($row as $key => $value) {
// Don't show any items that end with '_id'.
if(!preg_match('/_id$/', $key)) {
// Remove underscore of all field names.
$key = str_replace("_", " ", $key);
// Capitalize the first letter of each word.
$key = ucwords($key);
// Print results.
echo '<tr>
<th>'.$key.'</th>
<td>';
// Check if <br /> exists in $value.
if (preg_match("/\r\n/", $value)) {
$new_value = explode("\r\n", $value);
echo '<ul class="square">';
foreach ($new_value as $n_row => $n_value) {
echo '<li>'.$n_value.'</li>';
}
echo '</ul>';
} else {
echo nl2br(stripslashes($value));
}
echo '</td>
</tr>';
}
|