Jump to content

Need Help Php code preg_replace a php code


jimmyphong

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.