| Author |
removing link tags
|
|
|
| Hi,
I am creating a section that will allow certain members to view links and
other members to view the names of the links only. So basically I need to
have a list of links that I can show as links for one set of people and just
a plain text list for another.
I know how to so everything except how to trip out the a hrefs from the list
that will not be clickable. For that list I need to go through and replace
<a href="http://www.whatever.com"> and the closing </a> tag but not the
actual anchor.
Is there a PhP function that can do this efficiently? There could be
thousands of links.
tia,
Kelly
| |
| Dave Patton 2005-02-18, 3:56 am |
| "Kelly" <no@spam.com> wrote in news:8o7Rd.414902$6l.233041@pd7tw2no:
> Hi,
>
> I am creating a section that will allow certain members to view links
> and other members to view the names of the links only. So basically I
> need to have a list of links that I can show as links for one set of
> people and just a plain text list for another.
>
> I know how to so everything except how to trip out the a hrefs from
> the list that will not be clickable. For that list I need to go
> through and replace
><a href="http://www.whatever.com"> and the closing </a> tag but not the
> actual anchor.
You're doing it backwards. For each link, store(e.g. in
your database) the URI(e.g. "http://www.whatever.com")
and the link text(e.g. "WhatEver Company"). For some
members you build your output just using the link text,
for others you build the list by using the URI and
link text to create anchor tags.
--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website: http://members.shaw.ca/davepatton/
| |
|
| The only problem is I am not using a database. This is a file that is being
generated by someone else using a CMS so it will already be a link.
"Dave Patton" <spam@trap.invalid> wrote in message
news:Xns96008AC507C9Fmrzaphoddirectcaold
@24.71.223.159...
> "Kelly" <no@spam.com> wrote in news:8o7Rd.414902$6l.233041@pd7tw2no:
>
>
> You're doing it backwards. For each link, store(e.g. in
> your database) the URI(e.g. "http://www.whatever.com")
> and the link text(e.g. "WhatEver Company"). For some
> members you build your output just using the link text,
> for others you build the list by using the URI and
> link text to create anchor tags.
>
> --
> Dave Patton
> Canadian Coordinator, Degree Confluence Project
> http://www.confluence.org/
> My website: http://members.shaw.ca/davepatton/
| |
| Oli Filth 2005-02-18, 3:56 am |
| Kelly wrote:
> The only problem is I am not using a database. This is a file that is being
> generated by someone else using a CMS so it will already be a link.
>
>
In that case investigate regular expressions, specifically preg_replace().
http://www.php.net/manual/en/ref.pcre.php.
--
Oli
| |
| Matt Mitchell 2005-02-18, 3:56 am |
|
"Kelly" <no@spam.com> wrote in message
news:8o7Rd.414902$6l.233041@pd7tw2no...
> Hi,
>
>
> I know how to so everything except how to trip out the a hrefs from the
> list that will not be clickable. For that list I need to go through and
> replace <a href="http://www.whatever.com"> and the closing </a> tag but
> not the actual anchor.
>
preg_replace('/\<\/?a(\s[^\>]*)?\>/', '', 'some text with <a href=>tags</a>
in</a> it <a>');
there's also strip_tags too...
Matt
| |
| Matt Mitchell 2005-02-18, 3:56 am |
|
"Dave Patton" <spam@trap.invalid> wrote in message
news:Xns96008AC507C9Fmrzaphoddirectcaold
@24.71.223.159...
>
> You're doing it backwards. For each link, store(e.g. in
> your database) the URI(e.g. "http://www.whatever.com")
Whoops - looks like I didn't read the original post very carefully...
Matt
| |
|
| perfect thanks
"Matt Mitchell" < m_a_t_t_remove_the_underscores@metalspon
ge.net> wrote in
message news:hdaRd.71652$68.65643@fe1.news.blueyonder.co.uk...
>
> "Kelly" <no@spam.com> wrote in message
> news:8o7Rd.414902$6l.233041@pd7tw2no...
>
> preg_replace('/\<\/?a(\s[^\>]*)?\>/', '', 'some text with <a
> href=>tags</a> in</a> it <a>');
>
> there's also strip_tags too...
>
> Matt
>
>
| |
| Oli Filth 2005-02-21, 3:57 pm |
| Kelly wrote:
> The only problem is I am not using a database. This is a file that is being
> generated by someone else using a CMS so it will already be a link.
>
>
In that case investigate regular expressions, specifically preg_replace().
http://www.php.net/manual/en/ref.pcre.php.
--
Oli
| |
| Matt Mitchell 2005-02-21, 3:57 pm |
|
"Dave Patton" <spam@trap.invalid> wrote in message
news:Xns96008AC507C9Fmrzaphoddirectcaold
@24.71.223.159...
>
> You're doing it backwards. For each link, store(e.g. in
> your database) the URI(e.g. "http://www.whatever.com")
Whoops - looks like I didn't read the original post very carefully...
Matt
| |
| Matt Mitchell 2005-02-21, 3:57 pm |
|
"Kelly" <no@spam.com> wrote in message
news:8o7Rd.414902$6l.233041@pd7tw2no...
> Hi,
>
>
> I know how to so everything except how to trip out the a hrefs from the
> list that will not be clickable. For that list I need to go through and
> replace <a href="http://www.whatever.com"> and the closing </a> tag but
> not the actual anchor.
>
preg_replace('/\<\/?a(\s[^\>]*)?\>/', '', 'some text with <a href=>tags</a>
in</a> it <a>');
there's also strip_tags too...
Matt
|
|
|
|