php - String Replacement Within Tags -


This is my string that I am getting from an array area:

  [ Email_content] = & gt; Dear {NAME}, Thank you for connecting with {USR} "Company" Your username is {$ username}. {/ USR} {PWD} Thank you for connecting to "Company" Please click on the link given below to Resor Yor. {/ PWD} {$ password_link} Thanks & amp; Regards ABCD Team  

Sometimes I want to leave only the {USR} and {/ USR} tags of the entire string, along with the content between them left blank and never Never-I have tagged the whole material except by leaving both {USR} and {/ USR} both open and closing {USR}, leaving string content untouched.

I tried several string functions but it just made my coding tall.

How about:

  $ replacement = '$ 0 '; If ($ remove_tag_only) {$ substitution = '$ 1'; } And if ($ remove_all) {$ replacement = ''; } $ String = preg_replace ('~ \ ~ usr \} (. +?) \ {/ USR}}, $ substitution, $ string);  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -