Jump to content

Problem with PREG_MATCH_ALL


xsubs

Recommended Posts

I'm trying to get GENRE from IMDB.com.

I made this code:

<?php 
$site = file_get_contents('http://www.imdb.com/title/tt0458522');

// Genre finding

preg_match_all("/<a href=\"\/Sections\/Genres\/(.*?)\/\">/si" , $site , $GenreArr); 
$SizeoGenre = sizeof($GenreArr[1]);
echo $SizeoGenre; 
$Genre = "";

for ($i=0;$i<=$SizeoGenre;$i++) {
		$Genre .= $GenreArr[1][$i];
	if ($i !== $SizeoGenre) {
		$Genre .= " / ";
	}
}
?>

 

But it returns Biography / Drama / Music /

(The problem is that it returns wrong number of "/" signs)

 

What can i do to solve this?

Is there another better way to to it?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/74878-problem-with-preg_match_all/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.