As a perfectionist, I like having valid & correctly indented HTML outputted by PHP.
I have a few complex webapps with IT-minded users, and they like to be able to View source and not see a garbled mess.
Currently I use this function I wrote:
function nl($tabs = 0)
{
return "\r\n" . str_repeat("\t", $tabs);
}
Using it like so to add a newline and the required number of tabs:
if(array_key_exists('field', $row)){
echo '<td>' . $row['field'] . '</td>' . nl(4);
}
Is there anything built-in to PHP, or is there a class I can use to do this indentation automatically?