GSimpson
05-10-2009, 06:28 AM
Hey there,
I've recently taken a run at parsing links using php. I can't quite work out how to do it, so I'll just post what I'm trying to accomplish.
I have entries within a database, that include text and html. I've got that selected as $content.
I'm trying to get a function or set of functions to take this, and replace this:
<a href="http://myblog.com/">My Blog!</a>
with
[ url=http://myblog.com/]My Blog![ /url]
I just need to work out how to parse the link from within href="" and move it to after [url= then close it with ]. After that take what was within the anchor tags and put it between the [ url=] and [ /url] tags.
An ideas, or help?
Thanks everyone, Greatly appreciated.
Please ignore the spacing on the bb code, it was so that it would display on the forum.
I've recently taken a run at parsing links using php. I can't quite work out how to do it, so I'll just post what I'm trying to accomplish.
I have entries within a database, that include text and html. I've got that selected as $content.
I'm trying to get a function or set of functions to take this, and replace this:
<a href="http://myblog.com/">My Blog!</a>
with
[ url=http://myblog.com/]My Blog![ /url]
I just need to work out how to parse the link from within href="" and move it to after [url= then close it with ]. After that take what was within the anchor tags and put it between the [ url=] and [ /url] tags.
An ideas, or help?
Thanks everyone, Greatly appreciated.
Please ignore the spacing on the bb code, it was so that it would display on the forum.