I've run into a problem. Someone on our team edited a HTML/PHP file, and the entire contents of the file ended up on a single line. All line breaks and tabs were completely removed from the file. Its a very large file, so trying to edit it manually would take forever.
Does anyone know of a tool I can use to re-format the code?
Use the NetBeans IDE, for the development purpose. Then open the file in that IDE and press these keys at the same time - Alt + Shift + F.
The file will get formatted nicely, and also will show you if there are any errors in that file.
You could use DOMDocument
to tidy the HTML.
$dom = new DOMDocument();
$dom->preserveWhiteSpace = FALSE;
$dom->loadHTML($html);
$dom->formatOutput = TRUE;
echo $dom->saveHTML();
You can use tidy (html only) or codecleaner
(First link removed per comment below.)
http://www.phpformatter.com/ is an option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With