RE: [PHP] ereg() violence

From: Date: Wed, 08 Nov 2000 05:00:35 +0000
Subject: RE: [PHP] ereg() violence
Groups: php.general 
Request: Send a blank email to php-general+get-24262@lists.php.net to get a copy of this message
On your examples: --- : mode (1) <font color="FF0000" face="Verdana">HELLO WORLD &amp; 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, -----Original Message----- From: Jesse Binam [mailto:sirbinam@xmission.com] Sent: Wednesday, November 08, 2000 1:51 PM To: Maxim Maletsky; php-general@lists.php.net Subject: Re: [PHP] ereg() violence Maxim - I appreciate your feedback. my understanding of this thusfar is that it turns html tags into text by replacing characters like < with &gt; Am I wrong? What I am doing is making a mailing list app. When the author write the message they will choose whether the message is text or html. If it is text it sends it out. If it is html it needs to make a text version of the page to send to the members of the list that have requested text only messages. So I wouldn't want to change < to &gt; I want to change this: <font color="FF0000" face="Verdana">HELLO WORLD &amp; OTHER PEOPLE</font><br> <br> <img src="image.jpg"> into this: HELLO WORLD & OTHER PEOPLE <<image.jpg>> This is should be so easy. I would have thought that there would be an html2text() function or something to do this. I am sure that other people have done this I just can't find any other programs that do this. 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 9:19 PM Subject: RE: [PHP] ereg() violence > You can use HTML_ENTITIES, > > $trans = get_html_translation_table(HTML_ENTITIES); > $trans[" "] = "&nbsp"; > $html = strtr($original, $trans); > > this will transform every HTML-looking tag into the format that you can see > on a vebsite, > > then you adding and adding > ereg() > # after > ereg() > > can fix other issues.. > > Cheers > > > -----Original Message----- > From: Jesse Binam [mailto:sirbinam@xmission.com] > Sent: Wednesday, November 08, 2000 1:10 PM > To: php-general@lists.php.net > Subject: [PHP] ereg() violence > > > I have been screwing with this thing for 7 hours and CANNOT get it to work. > > When the author submits an html message the script needs to: > replace tags like <br>, <p>, <div> with \n > replace HTML codes with text equivelent like &amp; 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 > <<http://www.isp.com/images/pic.jpg>> > > But I am running into some serious problems!! > Either I can't get the regular expression right or it times out (possibly > because the regular expression is wrong) > I just don't know what to do. I think it would increase performance IF I > could somehow code it to replace only > what is there instead of searching for a every possible code whether it is > there or not. > > Suggestions on this would be GREATLY appreciated > > Jess > > > -- > 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 > > -- > 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 > >

« previous php.general (#24262) next »