Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts

    preg_match() problem

    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/realms...p?showtopic=36

    Here is the problematic code:

    PHP 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 "[url=http://imdb.com" $actores_raw[3] . "]" $actores_raw[4] . "[/url], ";
                if (
    strlen($actores_raw[6]) > && strlen($actores_raw[7]) > 5) {
                        
    $actors .= "[url=http://imdb.com" $actores_raw[6] . "]" $actores_raw[7] . "[/url], ";
                }
                if (
    strlen($actores_raw[9]) > && strlen($actores_raw[10]) > 5) {
                        
    $actors .= "[url=http://imdb.com" $actores_raw[9] . "]" $actores_raw[10] . "[/url], ";
                }
                if (
    strlen($actores_raw[12]) > && strlen($actores_raw[14]) > 5) {
                        
    $actors .= "[url=http://imdb.com" $actores_raw[12] . "]" $actores_raw[13] . "[/url], ";
                  }
                if (
    strlen($actores_raw[15]) >= && strlen($actores_raw[16]) >= 5) {
                        
    $actors .= "[url=http://imdb.com" $actores_raw[15] . "]" $actores_raw[16] . "[/url]";
                } 

  • #2
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    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....

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Alot of members aren't around over the weekend, be patient and give it time. Though, to debug, have you tried putting in:
    PHP Code:
    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.




  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •