etrader Posted February 2, 2011 Share Posted February 2, 2011 I have phrases in a string with the structure of "Note: some description" I want to replace "Note with (, but how can I replace the second " with )? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 use str_replace twice? $string = '"Note: some description"'; $string = str_replace('"Note: ','(', $string); $string = str_replace('"',')', $string); echo "string: $string"; Quote Link to comment Share on other sites More sharing options...
etrader Posted February 3, 2011 Author Share Posted February 3, 2011 Thanks for your suggestion, but this phrase is within a long string; the string is not limited to this phrase. I need a replacing method to look for "Note: ..... " Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 3, 2011 Share Posted February 3, 2011 same thing. neither the length of the string or other content in the string matter. <?php $string = 'AS FASDGASPING asdg aosgiha sgasgoiasrog rag 09u0er70 asr gas "Note: some description" asdga0idsajg0 s0gasrgho aisg'; $string = str_replace('"Note: ','(', $string); $string = str_replace('"',')', $string); echo "string: $string"; ?> output: string: AS FASDGASPING asdg aosgiha sgasgoiasrog rag 09u0er70 asr gas (some description) asdga0idsajg0 s0gasrgho aisg 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.