tserfer Posted November 15, 2013 Share Posted November 15, 2013 Helllo guys Lets say we have 2 strings that we want to replace . For example 1) rand( 2) mt_rand( (I know that these 2 are functions but lets say that they are strings). If i do: $source = preg_replace( "/rand\(/","NEW"); it will Replace the mt_rand as well and it will become mt_NEW( How can i fix it so that it will replace the whole function and not a part of it? We are talking about functions in strings Hope you understand Thanks Quote Link to comment Share on other sites More sharing options...
MDCode Posted November 15, 2013 Share Posted November 15, 2013 If there isn't a possible conflict, why not check for rand with a space in front, or not with an underscore in front? Quote Link to comment Share on other sites More sharing options...
.josh Posted November 15, 2013 Share Posted November 15, 2013 $string = preg_replace('~\brand\(~','new',$string); Quote Link to comment 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.