RE: [PHP-WIN] Strip text from HTML

From: Date: Mon, 12 Mar 2001 08:17:43 +0000
Subject: RE: [PHP-WIN] Strip text from HTML
Groups: php.windows 
Request: Send a blank email to php-windows+get-5950@lists.php.net to get a copy of this message
Thanks that did the trick. What I needed was to strip maybe the first paragraph of a article. The code you gave me would just strip one line of code. But it gave me the pointer I needed to find the final answer. I modified your code with other code I found in the manual and came up with the solution. And here it is..... <?php if ( $fp = fopen( "path/to/my/file/plus-the.file", "r" ) ) { while( ! feof( $fp ) ) { $line = fread ($fp, 800); if ( ! strpos( $line, "<P>" ) === false ) { echo $line; break; } } fclose( $fp ); } ?> <A HREF= "path/to/my/file/plus-the.file"><FONT SIZE="2">...More</FONT></A> This will display the first part of the article. Then the last part is if you want to see the rest of the article. > ---------- > From: Michael Rudel[SMTP:mru@suchtreffer.de] > Reply To: mru@suchtreffer.de > Sent: Saturday, March 10, 2001 12:42 AM > To: Mangiola Nunzio Datavia; 'PHP Windows List (E-mail)' > Subject: RE: [PHP-WIN] Strip text from HTML > > Hi Mangiola, > > yes you can. > > If the html-document is local on your server, you can "fopen" > it an then parse line for line like this: > > <?php > > if ( $fp = @fopen( "path/to/my/file/plus-the.file", "r" ) ) > { > while( ! feof( $fp ) ) > { > $line = fgets( $fp, 4096 ); > > if ( ! strpos( $line, "<P>" ) === false ) > { > echo $line; > break; > } > } > > fclose( $fp ); > } > ?> > > ... And if it's on a remote Host, then do the same but with "fsockopen" > (find help in the php-manual/Network Functions). > > Hope t'll help. > > Greetinx, > Mike > > Michael Rudel > - Web-Development, Systemadministration - > _______________________________________________________________ > > Suchtreffer AG > Bleicherstraße 20 > D-78467 Konstanz > Germany > fon: +49-(0)7531-89207-17 > fax: +49-(0)7531-89207-13 > e-mail: mailto:mru@suchtreffer.de > internet: http://www.suchtreffer.de > _______________________________________________________________ > > > > -----Original Message----- > From: Mangiola Nunzio Datavia [mailto:NunzioM@Datavia.co.za] > Sent: Friday, March 09, 2001 2:01 PM > To: PHP Windows List (E-mail) > Subject: [PHP-WIN] Strip text from HTML > > > Hi > > I'd like to strip the first paragraph > of a html document and display it. > > basically the introduction and no more. > > Is this possible? > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.windows (#5950) next »