refiking Posted August 20, 2009 Share Posted August 20, 2009 I have a string that I want to run in a query like this: $value = Martha_&_Mary_Popserburger; $newvalue = str_replace('_', ' ', $value); echo $newvalue; //$new value keeps getting cut off at Martha 0 Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/ Share on other sites More sharing options...
Daniel0 Posted August 20, 2009 Share Posted August 20, 2009 I assume you are talking about in a URL? Try urlencode. Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-902848 Share on other sites More sharing options...
Jacks89 Posted August 21, 2009 Share Posted August 21, 2009 $value = Martha_&_Mary_Popserburger; Try adding this "" to your value. Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-903030 Share on other sites More sharing options...
gergy008 Posted August 21, 2009 Share Posted August 21, 2009 I have a string that I want to run in a query like this: $value = Martha_&_Mary_Popserburger; $newvalue = str_replace('_', ' ', $value); echo $newvalue; //$new value keeps getting cut off at Martha 0 It's not a string unless it's surrounded by "s. The 'String' should be $value = "Martha & Mary Popserburger"; Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-903034 Share on other sites More sharing options...
kratsg Posted August 21, 2009 Share Posted August 21, 2009 I have a string that I want to run in a query like this: $value = Martha_&_Mary_Popserburger; $newvalue = str_replace('_', ' ', $value); echo $newvalue; //$new value keeps getting cut off at Martha 0 It's not a string unless it's surrounded by "s. The 'String' should be $value = "Martha & Mary Popserburger"; I would encourage 'single quotes' in this case if you truly want the string to be treated exactly like a literal string (also less processing time as you tell PHP you're not including any variables in it): $value = 'Martha & Mary Popserburger'; Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-903043 Share on other sites More sharing options...
refiking Posted August 27, 2009 Author Share Posted August 27, 2009 the $value line isn't in the script. That was just an example of how it looks. It's domain.com/Martha_&_Mary_Popserburger/ Where $value = everything between the /'s. What I want is for the entire value to be present. Right now, it cuts off at Mary because of the & symbol. I need the & included Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-907643 Share on other sites More sharing options...
Daniel0 Posted August 29, 2009 Share Posted August 29, 2009 Then use urlencode. Quote Link to comment https://forums.phpfreaks.com/topic/171209-how-do-i-escape-the-symbol/#findComment-908931 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.