I want to 'print' the output of a PHP file into a YAML
My original PHP output looks like this:
, and goes on for 150 more blocks.
As you can see, it has the YAML file structure. I would like to print that output into the YAML file so that those 150 blocks are written like this:
-
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...
Now, when I execute my PHP code using the file_put_contents($MyYamlFile, $PhpLoop)
function, I obtain the following code in my YAML file:
<br>-<br> ref: trade-Ref: trade-id
<br> id: Trade-ID
<br> name: Trade Name
#150 times...
...as expected.
So, my question is: How can I omit tags like <BR>
and  
, and dump exactly what localhost ouputs in the previous image?
If not, is there any other better method you can recommend?
You need to use str_replace() along with strip_tags()
something like:-
strip_tags(str_replace(" ","",$string),"<br/>");