flyhoney Posted September 9, 2008 Share Posted September 9, 2008 I'm working on a site that has a database with content that has accumulated about a kajillion slashes. Anyone know the best method to strip these slashes when echoing? Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/ Share on other sites More sharing options...
Minase Posted September 9, 2008 Share Posted September 9, 2008 what type of content are you storing in DB? it can be done by str_replace give an example how the result from db look and how you want to look at echo and i will do it. Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/#findComment-637612 Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 Are they in a row like \\\\\\\\\\ or one at a time? Are they backslashes or forward slashes? You can always do a replace and replace them with nothing. Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/#findComment-637614 Share on other sites More sharing options...
flyhoney Posted September 9, 2008 Author Share Posted September 9, 2008 It's just text, and I guess magic quotes is on and there is some addslashes going on and it is causing data that is edited and saved to slowly accumulate more and more slashes. Stuff like this: This is a silly slashy sentence, isn\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'t it? Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/#findComment-637616 Share on other sites More sharing options...
flyhoney Posted September 9, 2008 Author Share Posted September 9, 2008 yeah I guess str_replace is the best bet here Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/#findComment-637618 Share on other sites More sharing options...
Minase Posted September 9, 2008 Share Posted September 9, 2008 here it is your code $text = "This is a silly slashy sentence, isn\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'t it?"; $replace = str_replace ( "\\", "" ,$text); echo $replace; btw you have a problem when you update a value into database it do escape ' to \' show the update part and you dont need to replace and have those creepy slashes anymore Link to comment https://forums.phpfreaks.com/topic/123456-millions-of-slashes/#findComment-637622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.