jimmyphong Posted August 31, 2012 Share Posted August 31, 2012 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 Link to comment https://forums.phpfreaks.com/topic/267837-need-help-php-code-preg_replace-a-php-code/ Share on other sites More sharing options...
Christian F. Posted August 31, 2012 Share Posted August 31, 2012 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. Link to comment https://forums.phpfreaks.com/topic/267837-need-help-php-code-preg_replace-a-php-code/#findComment-1374133 Share on other sites More sharing options...
jimmyphong Posted August 31, 2012 Author Share Posted August 31, 2012 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 ! Link to comment https://forums.phpfreaks.com/topic/267837-need-help-php-code-preg_replace-a-php-code/#findComment-1374135 Share on other sites More sharing options...
Christian F. Posted August 31, 2012 Share Posted August 31, 2012 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. Link to comment https://forums.phpfreaks.com/topic/267837-need-help-php-code-preg_replace-a-php-code/#findComment-1374145 Share on other sites More sharing options...
hakimserwa Posted August 31, 2012 Share Posted August 31, 2012 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? Link to comment https://forums.phpfreaks.com/topic/267837-need-help-php-code-preg_replace-a-php-code/#findComment-1374162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.