regex in order to write only tags (html,php)

aAeroxyloody25

New Member
I have an HTML document which is pretty long. It has a table that may vary between 1000 and 1200 pixels wide (it changes each day). Lots of text, tables and sometimes embedded PDFs.I want to display on another page a short preview (like on online newspaper, where you can find title, a few sentences, maybe an image and then a link to the complete article).First problem: the page where I want the preview is only 800 pixel wide.My first idea was (in order to display only 10 sentences):\[code\]$lineswritten=0;$stream=fopen($document,"r");while ((($line = fgets($stream)) !== false)&&($lineswritten<10)){ if($lineswritten>=10) { echo "$line"; $line=trim($line); if($line!="") // if line is blank don't count it as text { $lineswritten=$lineswritten+1; } } } fclose($stream);\[/code\]But I have some problems. First of all: tags. Both the main and the preview pages are built with tables. If in the first 10 rows of the preview, they open a table but they doesn't close it, all the layout of the preview page is messed up.I tought of checking for table tags ( and ) with regex but I have not yet studied these expressions. Is it possible to check for these tags and write only them after row 10?Second problem.Images. I may have an image which is really big. Is it possible to retrieve just the image path from a tag? If that could be possible I can check the image dimensions and eventually scale it down.Third problemI have pdfs embedded with codes like:\[code\]<iframe src="http://docs.google.com/gview? url=http://www.mywebsite.ch/pdffolder/8121202.pdf&embedded=true" style="width:990px; height:700px;" frameborder="0"></iframe> \[/code\]Obviously width and height are not so easy: they may vary too. Is it possible to recognize strings like this and write them on the preview page with height:200px and fixed width of 700px ?Thank you very much!
 
Back
Top