Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I need opposite of strip_tags

0 views
Skip to first unread message

Randell D.

unread,
May 16, 2003, 3:54:19 PM5/16/03
to

Folks,

I am familiar with strip_tags() where it strips all the HTML and PHP tags
from a file... however, I want to do something almost opposite... I want to
scan an HTML file and retrieve a tag... I want allow a user to have a
template html file that can contain custom HTML tags that I can later read
and do something with... I want to do something more than just perform a
str_replace when the tag is found, as I want to permit my custom tag to have
parameters... thus... if I have the following in an HTML file

<CUSTOM HEIGHT=5 SOMETHINGELSE=4>

What function could I use in PHP that would alow me to retrieve that full
line of text? I gather someone might recommend preg_match or something,
however anything more than basic regular expressions are a bit difficult for
me...

All help appreciated - replies please via the newsgroup, thanks...
randelld


P'tit Marcel

unread,
May 17, 2003, 9:47:28 AM5/17/03
to
Randell D. écrivit:

> if I have the following in an HTML file
>
> <CUSTOM HEIGHT=5 SOMETHINGELSE=4>
>
> What function could I use in PHP that would alow me to retrieve that
> full line of text? I gather someone might recommend preg_match or
> something, however anything more than basic regular expressions are a
> bit difficult for me...

I haven't understood everything, but jumping to this point you may use :

$ok=preg_match_all('`<CUSTOM[^>]*>`i',$html_page,$reg);
if $ok is true then $reg is an array of all matching strings.

--
P'tit Marcel

Randell D.

unread,
May 19, 2003, 1:56:55 AM5/19/03
to

"P'tit Marcel" <geonona...@centrale-lyon.org.invalid> wrote in message
news:Xns937EA0A31...@213.228.0.136...

Okay... I think that should do it for me... and I gather I can later replace
the tag with preg_replace, true?

Thanks for the help


0 new messages