在我的HTML文件中,我有一个包含文件的php脚本。此时,代码缩进了2个制表符。我想做的是让php脚本每行都添加两个制表符。以下是示例:
主页面:
<body>
<div>
<?php include("test.inc"); ?>
</div>
</body>
还有"test.inc":
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
我能提供的内容:
<body>
<div>
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
</div>
</body>
我想要的是:
<body>
<div>
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
</div>
</body>
我意识到我可以向包含文件添加前导制表符。但是,当我对文档进行格式化时,VS会将它们删除。
preg_replace()
,使用str_replace()
就足够了。 - soulmergeecho str_replace("\n", "\t\n", "\t".$result)
пЉМдљЖињЩдїНзДґеѓєжИСйЭЮеЄЄжЬЙеЄЃеК©гАВ - Lime