Replacing some text with varying number with a link
Posted: Fri Feb 12, 2010 11:37 am
I need to change a text in a PHP page from this:
to this:
where the actual number (in this case, 23) is a varying number. Meaning, if the ticket was #87 (Ticket #87), the actual output would have been
I know I need to work with preg_replace, but it's been hours I still can't figure it out :') It's mainly storing the number in a variable to be reused with some sort of variable string ($1, $2) that poses a lot of problem to me when I'm trying to figure this out.
Any help is appreciated. Thanks
Code: Select all
Ticket #23 Code: Select all
<a href="http://www.somelink.com/ticket/23">Ticket #23</a> Code: Select all
<a href="http://www.somelink.com/ticket/87">Ticket #87</a> Any help is appreciated. Thanks