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); 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. 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']; 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 ! Link to comment https://forums.phpfreaks.com/topic/240942-replacing-b-with/#findComment-1237743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.