简体   繁体   English

如何制作 html 源格式

[英]How do I make the html source formatting

How do I make the html source formatting in php如何在 php 中制作 html 源格式

Sample:样本:

<?
    ob_start();

    $mixed_output = 
    "<div><div>2.</div><div>
          <div>4.</div>
             <div>4.</div>
    </div>  <div>2.</div>
      <div>2.</div>
    </div>";

    echo format_mixed_output($mixed_output);
?>

i want to be this:我想成为这样:

<html>
    <div>
      <div>2.</div>
        <div>
          <div>4.</div>
          <div>4.</div>
        </div>
      <div>2.</div>
      <div>2.</div>
    </div>
</html>

i can't find source in net, please help me...我在网上找不到源,请帮助我...

You can use " Tidy ".您可以使用“整洁”。

Example: http://www.php.net/manual/en/tidy.examples.basic.php示例: http://www.php.net/manual/en/tidy.examples.basic.php

Your example would be something like this:你的例子是这样的:

<?php
    $mixed_output = 
"<div><div>2.</div><div>
      <div>4.</div>
         <div>4.</div>
</div>  <div>2.</div>
  <div>2.</div>
</div>";

$config = array(
            'indent'         => true,
            'output-xml'     => true,
            'input-xml'     => true,
            'wrap'         => '1000');

$tidy = new tidy();
$tidy->parseString($mixed_output, $config, 'utf8');
$tidy->cleanRepair();
echo tidy_get_output($tidy);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM