...

View Full Version : preg_match() problem



Element
09-02-2006, 09:31 AM
I have a problem with a modification I downloaded for IPB. It is a IMDb.com mod to feed some infor about a movie through fopen to use as a BBcode tag for IPB.


It seems that it catches the wrong HTML for the cast of movies from http://imdb.com. Right now it catches the end of the page and the links... that is wrong... Here is what the result is (Look at the cast part)


http://amerikanmetz.rave5.com/realmscommunity/index.php?showtopic=36

Here is the problematic code:



preg_match ( "'(Cast overview,|Complete credited cast|Credited cast)(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)<a href=\"(.*?)\">(.*?)</a>(.*?)'s" , $imdb_raw , $actores_raw );
for($i = 0; $i < count($actors_raw); $i++) {
strip_tags($actores_raw[$i], '<a>');
}
$actores = " . "]" . $actores_raw[4] . " (http://imdb.com" . $actores_raw[3), ";
if (strlen($actores_raw[6]) > 5 && strlen($actores_raw[7]) > 5) {
$actors .= " . "]" . $actores_raw[7] . " (http://imdb.com" . $actores_raw[6), ";
}
if (strlen($actores_raw[9]) > 5 && strlen($actores_raw[10]) > 5) {
$actors .= " . "]" . $actores_raw[10] . " (http://imdb.com" . $actores_raw[9), ";
}
if (strlen($actores_raw[12]) > 5 && strlen($actores_raw[14]) > 5) {
$actors .= " . "]" . $actores_raw[13] . " (http://imdb.com" . $actores_raw[12), ";
}
if (strlen($actores_raw[15]) >= 5 && strlen($actores_raw[16]) >= 5) {
$actors .= " . "]" . $actores_raw[16] . " (http://imdb.com" . $actores_raw[15)";
}

Element
09-04-2006, 07:35 AM
Was this topic overlooked or is it that stupid? I honestly can't figure out why it is not grabbing the text it needs to....

Brandoe85
09-04-2006, 07:54 AM
Alot of members aren't around over the weekend, be patient and give it time. Though, to debug, have you tried putting in:


echo '<pre>';
print_r($actores_raw);
echo '</pre>';
To check your matches? You should get a few matches i'd presume. Assuming $imdb_raw is the source.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum