Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 511507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:13:25+00:00 2026-05-13T07:13:25+00:00

I have a class that generates some html (form elements and table elements), but

  • 0

I have a class that generates some html (form elements and table elements), but this class returns all the html in one line.

So I am trying to use tidy to beautify the code (indent the code, put line breaks, etc), the only problem I am having is that’s also generating the tags I don’t want.

Here is the code:

tidy_parse_string(
                    $table->getHtml(),
                    array(
                            'DocType' => 'omit',
                            'indent' => true,
                            'indent-spaces' => 4,                                    
                            'wrap' => 0                                    
                        )
                );

The only way I have found to remove the extra html tags is by adding a str_replace, something like this:

str_replace(array('<html>','</html>','<body>','</body>','<head>','</head>','<title>','</title>'),'', code);

Which works, but I was really hopping there would be a way to tell tidy to just beautify the code and not insert the extra code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:13:25+00:00Added an answer on May 13, 2026 at 7:13 am

    Try the show-body-only option.

    e.g.

    $s = '<form method="post" action="?"><table><tr><td><input tpye="submit"></table>';
    echo tidy_parse_string($s, array('show-body-only'=>true, 'indent'=>true));
    

    prints

    <form method="post" action="?">
      <table>
        <tr>
          <td>
            <input tpye="submit">
          </td>
        </tr>
      </table>
    </form>
    

    (string has been repaired and indented but no html/body wrapper added).
    Can be combined with the output-xhtml option which in this case would also add the slash for the empty input element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this c# class that calculates n choose k and then generates all
I have a class Foo, with a method that generates HTML that is displayed.
I have an xml document that contains some html. <begin-line> <verse-num>6</verse-num>a mixed people<footnote id=f2>
I have a php class that generates a map image depending on my db
I have class that looks like this: class A { public: class variables_map vm
I have a form in my forms.py that looks like this: from django import
I have a C# application that generates an html document from transforming an xml
I have a class that has the following property that is generated by the
I have a constructor (for an auto generated class) that has 255 paremeters. Using
I have a buffer in class 'bufferClass' that will generate a signal to tell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.