[ Sasa Kostic @ 10.09.2007. 11:25 ] @
php fajl je:
Code:

<?
$url='file.html';
$file=fopen($url,"r");
while(!feof($file)){
$buffer.=fgets($file,4096);
}
preg_match_all("/(http|https)?:\/\/?([a-zA-Z0-9\-\.]*\.[a-zA-Z]{2,5})(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9.-_]*\/)?([a-zA-Z0-9.-_?&=%+$]+)?/", $buffer , $arrAddress );
$key=0;
foreach($arrAddress as $arr){
echo $arr[$key].'<br>';
$key++;
}
fclose($file);
?>


html fajl je:
Code:
<html>
<head>
<title>Apache localhost homepage</title>
</head>
<body bgcolor="#FFFFFF" text="#5599ff" link="#888888" vlink="#888888">
<center>
<br>
<br>
<br>
<br>
<h1><strong>Apache server</strong></h1>
<a href="http://www.site1.com/cgi-bin/this/search.cgi">Projects</a><br>
<a href="https://www.site2.com/cgi-bin/fres/dot.cgi?manage=1">Account</a><br>
<a href="http://localhost/phpmyadmin/">MyAdmin</a><br>
<a href="https://www.dem2.com/cgi-bin/ln/lox.cgi?viewprofile=miok">Profile</a><br>
<a href="http://localhost/phpmyadmin/tb...a2cc070f9f809b&table=links">Settings</a>
<br><a href="http://localhost/hind.com/">SIte.com</a><br>
<a href="http://www.tugos-edu.net/notes...7122c75ad4b2787a0e6f8d3ae21587">FAX</a><br>
<a href="http://localhost/ex">ex</a><br><a href="http://localhost/sl">sl</a><br>
<a href="http://localhost/dev">dev</a><br></center>

</body>
<html>


sve sto daje je:

Code:

http://www.site1.com/cgi
https
www.dem2.com



imam instaliran xampp na windows xp-u

[Ovu poruku je menjao Sasa Kostic dana 13.09.2007. u 15:38 GMT+1]
[ Br@nkoR @ 11.09.2007. 11:35 ] @
Odradi:
Code:
print_r($arrAddress);

kako bi video šta ti vraća preg_matsh_all.
[ Sasa Kostic @ 13.09.2007. 14:39 ] @
Za chudo, ta komanda prikazuje da je svaki link pokupljen. Medjutim prilikom listanja linkova ne znam sta se desava. Ne listaju se svi samo 2-3
[ agvozden @ 14.09.2007. 08:10 ] @
Code:
$key=0;
foreach($arrAddress as $arr){
echo $arr[$key].'<br>';
$key++;
}


Čemu ti služi $key u foreach petlji?!!

Zar ne bi trebalo da koristis echo $arr[0] ili $arr[1]?
Ili jednostavno $arrAddress[$key]

Ne mogu da verujem da radis sa reg exp a da zabrljas na osnovnoj lekciji...