将 PHP 内容传递给 YAML 文件时,如何 omit/ignore 标签如 <br>?

How to omit/ignore tags like <br> when passing PHP content to a YAML file?

我想'print'一个PHP文件的输出到一个YAML

我的原始 PHP 输出如下所示:

,然后再走 150 个街区。

如您所见,它具有 YAML 文件结构。我想将该输出打印到 YAML 文件中,以便将这 150 个块写成这样:

  -
        ref: trade-67
        id: 67
        name: Plumber
        category: $trade-category-1
    -
        ref: trade-68
        id: 68
        name: Electrician
        category: $trade-category-2  
    -
#and so on...

现在,当我使用 file_put_contents($MyYamlFile, $PhpLoop) 函数执行我的 PHP 代码时,我在我的 YAML 文件中获得以下代码:

    <br>-<br>    &nbsp;&nbsp;ref: trade-Ref: trade-id
    <br>    &nbsp;&nbsp;id: Trade-ID
    <br>    &nbsp;&nbsp;name: Trade Name

#150 times...

...符合预期。

所以,我的问题是:如何省略 <BR>&nbsp 等标签,并准确转储上一张图片中本地主机的输出?

如果没有,有没有其他更好的方法可以推荐?

您需要使用str_replace() along with strip_tags()

类似于:-

strip_tags(str_replace("&nbsp;","",$string),"<br/>");