1

I want remove this line from my config file

line :define('APP_MAIL_FROM_EMAIL_NAME','example'); 

Here is my code

<?php $configFileContents = file_get_contents('config.php'); if (!empty($configFileContents)) { if (strstr($configFileContents, 'define(\'APP_MAIL_FROM_EMAIL_NAME\',')) { $configFileContents = preg_replace('/define\(\'APP_MAIL_FROM_EMAIL_NAME.*\R/', '', $configFileContents); } file_put_contents("config.php", $configFileContents); } ?> 

This code working fine but if that line like this

line :define('APP_MAIL_FROM_EMAIL_NAME' ,'example'); 

if space present between APP_MAIL_FROM_EMAIL_NAME' , and comma its not working what is the problem any changes needed what??

2
  • remove \R from the regex, or make it optional Commented Sep 1, 2015 at 14:13
  • even if i removed \R not working . and also its removing only content but not removing entire content Commented Sep 1, 2015 at 14:20

1 Answer 1

1

Try this it will include all space between your character

preg_replace('/define\(\'APP_MAIL_FROM_EMAIL_NAME.s+*\R/', '', $configFileContents); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.