dadamssg Posted June 27, 2009 Share Posted June 27, 2009 I have no idea how to write the function i need. But i want the function to replace all '&'s with "and" within a string. does anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
.josh Posted June 27, 2009 Share Posted June 27, 2009 $string = preg_replace('~&~','and',$string); Quote Link to comment Share on other sites More sharing options...
thebadbad Posted June 27, 2009 Share Posted June 27, 2009 I'm sure you know this CV, but for the sake of the OP; when replacing simple strings, str_replace() is more efficient. $str = str_replace('&', 'and', $str); Quote Link to comment Share on other sites More sharing options...
.josh Posted June 27, 2009 Share Posted June 27, 2009 Ah yeah, for some reason it just slipped my mind. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted June 27, 2009 Author Share Posted June 27, 2009 thank you thank you thank you! 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.