newbtophp Posted December 8, 2009 Share Posted December 8, 2009 Hmm im having abit of trouble, how would i replace: ;echo ' '; (contains a new line after opening quote). with: ?> <?php Example: <?php include("../config.php"); ;echo ' '; $variable = "test"; echo $variable; ?> Would turn into: <?php include("../config.php"); ?> <?php $variable = "test"; echo $variable; ?> :-\ Quote Link to comment https://forums.phpfreaks.com/topic/184425-preg_replace-trouble/ Share on other sites More sharing options...
newbtophp Posted December 8, 2009 Author Share Posted December 8, 2009 My try - altough no luck: $variable = preg_replace("#;echo '[\s]';#", "?>\r\n<?php", $variable); Quote Link to comment https://forums.phpfreaks.com/topic/184425-preg_replace-trouble/#findComment-973547 Share on other sites More sharing options...
salathe Posted December 8, 2009 Share Posted December 8, 2009 Do you really need a regular expression? $variable = str_replace(";echo '\n';", "?>\n<?php", $variable); (If the string contains \r\n style newlines, use that instead of just \n.) Quote Link to comment https://forums.phpfreaks.com/topic/184425-preg_replace-trouble/#findComment-973605 Share on other sites More sharing options...
newbtophp Posted December 8, 2009 Author Share Posted December 8, 2009 Do you really need a regular expression? $variable = str_replace(";echo '\n';", "?>\n<?php", $variable); (If the string contains \r\n style newlines, use that instead of just \n.) Thanks mate!! works perfect.! Quote Link to comment https://forums.phpfreaks.com/topic/184425-preg_replace-trouble/#findComment-973619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.