Jump to content


Photo

Content extraction


  • Please log in to reply
3 replies to this topic

#1 CodilX

CodilX
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 June 2006 - 07:25 AM

Hi again :)

Now I'm having trouble extracting a portion of content out of page. Basicly it looks like this:

some content
..
..
<img src="someimage.jpg">
multiple lines of content that I want to extract
...
<div id="something">
.. some content

I'm trying to do it with if (stristr($text, "<img src="someimage.jpg">")) { .. but with no luck :(

Can somebody help me with this?

Thx - Matt

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 18 June 2006 - 02:27 PM

You may want to use regex:

preg_match('/<img src="someimage.jpg">(.*?)<div id="something">/', $string, $matches);

echo '<pre>';
print_r($matches);
echo '</pre>';

~ D Kuang

#3 CodilX

CodilX
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 June 2006 - 02:56 PM

[!--quoteo(post=385295:date=Jun 18 2006, 05:27 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 18 2006, 05:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You may want to use regex:

preg_match('/<img src="someimage.jpg">(.*?)<div id="something">/', $string, $matches);

echo '<pre>';
print_r($matches);
echo '</pre>';
[/quote]

Thx alot, but it doesn't go with my code. Could you write that with the connection to the site?

I get an error:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Warning: preg_match() [function.preg-match]: Unknown modifier 't' in ...*.php on line 5

Array
(
)
[/quote]

#4 CodilX

CodilX
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 19 June 2006 - 07:48 AM

*bump*




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users