help with includes / font tag – PHP

  php

Q(Question):

Hi,

I was wondering how I would be able to strip the <font> tags from a file
when I include it so it can take on the characteristics of my own stylesheet
instead of the font tag attributes.

Thanks in advance!
John

A(Answer):

On 2004-01-23, John <gt*****@mail.gatech.edu> wrote:

Hi,

I was wondering how I would be able to strip the <font> tags from a file
when I include it so it can take on the characteristics of my own stylesheet
instead of the font tag attributes.

So you want to _replace_ the string "<font>" by the string "" ?

http://www.php.net/manual/function.str-replace.php

http://home.mysth.be/~timvw

A(Answer):

"John" <gt*****@mail.gatech.edu> wrote in message
news:bu**********@news-int2.gatech.edu…

Hi,

I was wondering how I would be able to strip the <font> tags from a file
when I include it so it can take on the characteristics of my own
stylesheet instead of the font tag attributes.

Thanks in advance!
John

$text = preg_replace("'<font[^>]*?>(.*?)</font>’si","\\1",$text);

Although you may have to watch out for style="blah" and class="blah"
attributes in other html tags

HTH

Cheers,
thunder

A(Answer):

On 2004-01-23, Tim Van Wassenhove <eu**@pi.be> wrote:

On 2004-01-23, John <gt*****@mail.gatech.edu> wrote:

Hi,

I was wondering how I would be able to strip the <font> tags from a file
when I include it so it can take on the characteristics of my own stylesheet
instead of the font tag attributes.

So you want to _replace_ the string "<font>" by the string "" ?

http://www.php.net/manual/function.str-replace.php

You could replace all occurences of <font (.*?)> with a regular
expression. And the </font> tags with str_replace.

If you try to match them with 1 regular expression, you run into problems when you
have nested tags, fe: <font><font></font></font>.


http://home.mysth.be/~timvw

A(Answer):

John wrote:

I was wondering how I would be able to strip the <font> tags from a file
when I include it so it can take on the characteristics of my own stylesheet
instead of the font tag attributes.

You could use an HTML parser of sorts to remove tags. One regular
expression would probably be insufficient.

On the other hand, you could make a rule in your stylesheet to
override presentational effects that the font element would suggest.
Better to remove it though, in general.


Jock

A(Answer):

"John Dunlop" <jo*********@johndunlop.info> wrote in message

On the other hand, you could make a rule in your stylesheet to
override presentational effects that the font element would suggest.
Better to remove it though, in general.

I wasn’t aware that was possible… what’s the command for that?

Thanks in advance!

A(Answer):

John wrote:

"John Dunlop" <jo*********@johndunlop.info> wrote in message

On the other hand, you could make a rule in your stylesheet to
override presentational effects that the font element would suggest.
Better to remove it though, in general.

I wasn’t aware that was possible… what’s the command for that?

There is no command, only suggestions. (See CSS2, sec. 6.4.4.)

That doesn’t remove font tags from your markup though.


Jock

LEAVE A COMMENT