php - How can I insert text in an html element stored in a variable? -


I have a program copying text from another website and showing it.

This is accumulating text in a variable $ string .
There are variables containing html tags and I want to add text before the html tag stored in the variable. .

For example: $ string = "

I want to add code before div whose ID is game .

To add text before the divi whose ID is 'game' simply use:

  $ string = "& lt; div id = '1' & gt; div id = 'game' & gt; & lt; / div & gt;"; $ New = "TextInstruct"; $ Pos = "& lt; div id = 'game' & gt; & lt; / div & gt;"; Echo str_replace ($ pos, $ new. $ Pos, $ string);    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -