Clarkeez Posted July 2, 2011 Share Posted July 2, 2011 Hey, Can someone help me on replacing with <b>? heres i what i got so far but it doesnt work. $text = str_replace('[b]', '<b>', $data['post']); $text = str_replace('[/b]', '</b>', $data['post']); echo $text); Quote Link to comment https://forums.phpfreaks.com/topic/240942-replacing-b-with/ Share on other sites More sharing options...
.josh Posted July 2, 2011 Share Posted July 2, 2011 I see a ")" in your 3rd line that shouldn't be there. Quote Link to comment https://forums.phpfreaks.com/topic/240942-replacing-b-with/#findComment-1237603 Share on other sites More sharing options...
wildteen88 Posted July 2, 2011 Share Posted July 2, 2011 You're close $data['post'] = str_replace('[b]', '<b>', $data['post']); $data['post'] = str_replace('[/b]', '</b>', $data['post']); echo $data['post']; Or you can use regex $data['post'] = preg_replace('~\[b\](.*?]\[/b\]~', '<b>$1</b>', $data['post']); echo $data['post']; Quote Link to comment https://forums.phpfreaks.com/topic/240942-replacing-b-with/#findComment-1237605 Share on other sites More sharing options...
Clarkeez Posted July 2, 2011 Author Share Posted July 2, 2011 Thanks very much ! Quote Link to comment https://forums.phpfreaks.com/topic/240942-replacing-b-with/#findComment-1237743 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.