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 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. 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. 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"; 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'; 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 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. 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
Archived
This topic is now archived and is closed to further replies.