Why doesn't this regular expression work with reading files and PHP? It works for other files though

I have this code that I wrote to make my life easier when downloading .torrents, the code is as follows:

$file = 'http://kat.ph/new/';
if($file = file_get_contents($file)) {
    // RETURN ALL MAGNET URIS FROM FILE
    preg_match_all('/\"magnet\:\?xt\=urn\:btih\:(.*?)\"/x', $file, $magnetURI);
    // FOR EACH MAGNET URI RETURNED
    foreach($magnetURI[1] as $info) {
        echo '<a href="magnet:?xt=urn:btih:' . $info . '">' . $info . '</a><br /><br /><br /><br />';
    }
} else {
    echo '<strong>FAIL</strong>';
}

It is assumed that links to magnetic uri links and return them to me in readily accessible links, it works on other sites, try replacing the file http://thepiratebay.se/recent/0, but for some reason the website in the example will not work?!?

Thank you for your help!

+3
source share
1 answer

It works for me , try removing the modifier x.


file_get_contents(), , kat.ph , $file, , :

  } r Ʋ o )&\ˑ\@ Aڒ I   X   8Y; r  !     Ĭ     ϓ    .     ey ĥg 랾  ; u޻  :  Q6    9 Q [e  E ~vv  J  Z ٬  =5  n-̒>Ũc Q O   ip [s (cQ& & F< m      T^oD  e  l 7j   e  ]K K ţ ݚ R/ &YG   x  |  gQS D  dq     ~ ӌ 32 2HS8 , B  )z  x'4M S;uq ӝ0 NH   Z  OG e5    Q   zhd4<ŋ u    Ug  o+    H b 8ɼiFY  f0 C   oR  e*t2  x   Մ.߭L     , H  7]  Q q=1fW      "? ! {O/5  f  IH    [ DO 8Y#i ]i S 5 R> ,=  SG  _ G  4o ,4 X XcS  36    wl Vr 0D _I Ì% X *s Q  $M s4r|  ֎ }$ g`+   0 c#7 '4S& :| ~    $  S d   y     8   u{   M=P㩑    [oN    ?  h` /ћ}    R| A   z; 0( (   Q    = 8   >І[ ㆻF,  ]  M    6!  =a4GW +o   z  o۩s s    ] 0  H b     # /d  Z /ԕߌ6 P | gE V   dz ćz   | zl ɗ )  i   e $ /"  l ʟ )    K ʗx  Ʉ  :9'H $ 2 ؓP , r/  +Fcmq] P|   n 

( file_get_contents() HTTP CURL).

+1

All Articles