supanoob Posted July 24, 2006 Share Posted July 24, 2006 well i have a function to change [ & ] to < & > but it doesnt seem to change the [/ & ] part at the end of the code. this is the function:[code]function tml ($topbody) { $topbody=htmlspecialchars($topbody); $topbody=str_replace('[b]','<b>',$topbody); return nl2br($topbody); }[/code]and whenever i type [ b] it works but whenever i put [/ b] it doesnt :S Quote Link to comment https://forums.phpfreaks.com/topic/15531-str-functions/ Share on other sites More sharing options...
Barand Posted July 24, 2006 Share Posted July 24, 2006 [code]str_replace (array('[b]', '[/b]'), array('<b>', '</b>'), $topbody)[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15531-str-functions/#findComment-63093 Share on other sites More sharing options...
effigy Posted July 24, 2006 Share Posted July 24, 2006 ...or regex:[code]<?php echo preg_replace('%\[(/?b)\]%', "<$1>", '[b]This[/b] is bold.');?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15531-str-functions/#findComment-63097 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.