Insert string between two points with PHP

前端 未结 4 872
天涯浪人
天涯浪人 2021-01-06 13:18

How would I insert text between two comments like the ones below with PHP. Thanks in advance.




         


        
4条回答
  •  别那么骄傲
    2021-01-06 13:51

    Maybe just insert after first tag ?

    $afterinsert = str_replace( "INSERT 1 -->" , "INSERT 1 -->\n".$toinsert , $beforeinsertion );
    

    If you want to insert only when there are both tags, use preg_replace.

提交回复
热议问题