RE: [PHP] ereg() violence
| From: | Maxim Maletsky | Date: | Wed, 08 Nov 2000 05:37:04 +0000 |
| Subject: | RE: [PHP] ereg() violence | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24270@lists.php.net to get a copy of this message | ||
OK, I got it...
it is needed for emails, (sorry, in fact you said html2text() should have
guessed it..)
well then there's no function to do that that I knew.
What you can do is to write a class that does that,
use multiple regular expressions in it, depending on the text itself:
class... {
if(strstr('<a href',$body))
#a regex that will replace all links to link title <URL>
eregi_replace("<P>", '\n\n', $body);
eregi_replace("<BR>", '\n', $body);
eregi_replace("<[ibu/]*>", '', $body); # this will get rid of usless B I U
tags, you add here what you want to..
eregi_replace("<HR[^>]>", '---------------------------------', $body);
# and so on ... Yeah, this is a pain, but I have no idea about what
function you could use.
# I guess if you would search some code archives you could find some class
that does that.
# Probably people used to have this problems before too
}
Cheers,
Maxim Maletsky
-----Original Message-----
From: Jesse Binam [mailto:sirbinam@xmission.com]
Sent: Wednesday, November 08, 2000 2:14 PM
To: Maxim Maletsky; php-general@lists.php.net
Subject: Re: [PHP] ereg() violence
Your misunderstanding is that this isn't going to a browser it is going to
an email client like outlook or netscape mail.
If a member asks for text email and I send them the HTML code that is
exactly what they see... the HTML code.
If a member asks for HTML email and I send them the HTML code it will show
up like it would on a web page.
So I need to take the HTML code that the author writes and strip it down to
just ASCII text and replace tags like
<br>, <p>, <div> with a new line replace HTML codes with text equivelent
like & with & strip all other HTML
tags that have no place in a text message like <b>, <font>, etc. and it
would be nice if it would find the img tags and
replace them with something like <<image.jpg>> so that even the users that
can't see the image know that there is
suppose to be one there.
Is this a little more clear?
Thanks,
Jess
----- Original Message -----
From: Maxim Maletsky <maxim.maletsky@japaninc.net>
To: 'Jesse Binam' <sirbinam@xmission.com>; <php-general@lists.php.net>
Sent: Tuesday, November 07, 2000 10:00 PM
Subject: RE: [PHP] ereg() violence
>
> On your examples:
>
> --- : mode (1)
> <font color="FF0000" face="Verdana">HELLO WORLD & OTHER
> PEOPLE</font><br>
> <br>
> <img src="image.jpg">
> ---
>
> --- : mode (2)
> HELLO WORLD & OTHER PEOPLE
>
> <<image.jpg>>
> ---
>
> mode (2) will be visible within a browser.
> So I don't think you should do there anything except addslashes() and
> stripslashes(),
>
> You can then have the mode (1) inside a database and just echo it on a
page:
> it will be seen as mode (2)
>
> Then if someone checks box saying it's a text format what you need will be
> just make it look like mode (1) (itself) with htmlentities()
>
> I guess I don't understand what exactly you meant..
>
> Cheers,
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net