Jump to content

Recommended Posts

can anyone help me complete my php code with preg_replace

$content = @file_get_contents($filename);

$str_regex = '$query = $db->query("SELECT * FROM tbl_setting WHERE store_id = \'0\'");'

$str_replace = 'my replace code';

$content = preg_replace($str_regex , $str_replace , $content);

 

but it doesn't work !!

 

Anyhelp many thanks

 

Regards

You want to use str_replace (), as the "regex" you have is not a Regular Expression

 

Also, I strongly recommend that you read this article before the next time you're going to ask for help.

 

yes , i want use preg_replace !

can be convert this to Regular Expression

 

Thanks !

Yes it can.

I got an even better question, for you this time: Why do you insist upon Regular Expressions?

 

Note I'd normally not reply to this, seeing as you clearly didn't read the article I linked you to. If you have troubles understanding English, there's a number of translations available. This time, do make sure to read and adhere to its teachings. For your own good.

can anyone help me complete my php code with preg_replace

$content = @file_get_contents($filename);

$str_regex = '$query = $db->query("SELECT * FROM tbl_setting WHERE store_id = \'0\'");'

$str_replace = 'my replace code';

$content = preg_replace($str_regex , $str_replace , $content);

 

but it doesn't work !!

 

Anyhelp many thanks

 

Regards

can you just explain what you are trying to do?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.