Is there a way to do a condition preg_replace so it replaces the value of 1 to Yes and 0 to No?
I know that it is as easy as doing an if statement, but my question refers to using the preg_replace only, to learn and understand the conditional replace.
Thanks
you dont need a regex for that you can simply use str_replace()
As I said and understand that, I'm trying to learn and understand the a regular expression conditional replace if possible?
Any solution on the regular expression replace preg_replace()?
you set the conditions of the replace, you chose 0 to NO, or red to green.
$pattern='/0/'; $replacement='NO'; $string=' 0 or yes'; preg_replace($pattern, $replacement, $string);