Page 1 of 1
Convert HTML to text , for NEWS Abstract !
Posted: Sat Feb 04, 2006 7:11 pm
by iranPHPmaster
hello
i have a news system ,i want show news abstract in home page with an image thumbnail.
i need to Convert HTML to text , and get all image tag for creating thumbnail.
but i dont know how can i catch all image tag SRC value !
please help me
thx

Posted: Sat Feb 04, 2006 7:18 pm
by feyd
The following is a response I gave to Heavy, which has code tucked away inside it to do what you want, and much more.
viewtopic.php?t=29312
i see that post , but i dont understand how can i use that !
Posted: Sat Feb 04, 2006 7:31 pm
by iranPHPmaster
hi
thx for reply !
but i dont understand how i must use that code for this abstract !!!
can you say to me easyer !
Posted: Sat Feb 04, 2006 7:35 pm
by feyd
I can't make it much simpler without doing it for you. I'm not going to do the work for you. The regex needed is inside the code I posted for Heavy. Find it, play with it.
in easy sample !
Posted: Sun Feb 05, 2006 8:02 am
by iranPHPmaster
if i want Export name of Image From Tag same this :
Code: Select all
<img class="a" src="a.jpg" width="10">
i must use ????
i use this :
and i get export this :
its not work , help

?!
Posted: Sun Feb 05, 2006 8:33 am
by feyd
ready the stickies. Search for greedy/ungreedy.
Posted: Sun Feb 05, 2006 3:49 pm
by iranPHPmaster
thx
Feyd !
whats your idea about this code ?
Code: Select all
<?php
$input=implode('',file('http://www.yahoo.com'));
$count_found=preg_match_all("#<img.*src=[\"\'](.*)(.gif|.jpg|.jpeg|.png|.bmp)[\"\'].*>#i", $input, $matches);
print "$count_found Item Found<br><br>";
for($i=0;$i<=$count_found-1;$i++) {
print "- Item[$i] = {$matches[1][$i]}{$matches[2][$i]}<br>";
}
//print_r($matches);
?>
i think its good , but not completed ?!
i must abstract an html with style !!!?
sample :
we have and heavy html file , i want catch some line of it with Style !!!
who its possible ?
Posted: Sun Feb 05, 2006 4:14 pm
by Chris Corbyn
.* is greedy... it will mess your regex up. Use .*?