Trying to file_get_contents an .flv file

Discussion in 'PHP' started by Choller, Jul 2, 2007.

  1. #1
    I'm trying to see if a link is a .flv file or not. So I grab only the first part of the url because it always starts with "FLV". At least that's what I get when i "echo $content;".

    Here is a piece of the code.

    
        $content=@ file_get_contents($url,FALSE,NULL,0,100);
        if (strpos($content,'FLV')===true && strpos($content,'FLV')==0) {
            echo 'FLV file exists.';
            continue;
        }
    
    PHP:
    However i'm not getting any results. Am I doing something wrong?
     
    Choller, Jul 2, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    strpos() doesn't ever return boolean true. It's returns boolean false if the string was not found, and the position as integer if found.

    www.php.net/strpos


    Try:
    
    if (strpos($content,'FLV') === 0)
    {
        echo 'FLV file exists.';
    }
    
    PHP:
     
    nico_swd, Jul 2, 2007 IP
  3. Choller

    Choller Peon

    Messages:
    388
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yessss that's it. thanks!
     
    Choller, Jul 2, 2007 IP