turkman Posted March 16, 2010 Share Posted March 16, 2010 Hey im making a forum and when people enter posts it strips the html... i do however want to give people the option of linking to an earlier post. i.e say the post reference was 10001 in their post they could type #10001 and the php would recognise the # as wanting to make a link and would change it to <a href = '#10001'>#10001</a> Is this easily done? Link to comment https://forums.phpfreaks.com/topic/195485-help-with-a-way-from-making-links-using-regex-or-an-easier-way/ Share on other sites More sharing options...
sasa Posted March 17, 2010 Share Posted March 17, 2010 try <?php $test = 'blah #123 blah blah #4567 #sasa'; $out = preg_replace('/#[^ ]+/', '<a href=\'$0\'>$0</a>', $test); echo $out; ?> Link to comment https://forums.phpfreaks.com/topic/195485-help-with-a-way-from-making-links-using-regex-or-an-easier-way/#findComment-1027755 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.