tags:

views:

44

answers:

2

This is my function http://www.ideone.com/slpPe

If i don't use function

    preg_match_all("{http://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}[^\s\"\\\'\<&]*}ix", $html, $marches);
    $download = $marches[0];
//var_dump();
    $i = 0;
    for ($i; $i <= count($download); $i++) {
        echo  "download|";
        $links = $download[$i];
        if (!eregi("avaxhome.ws|pixhost.info", $links)) {
            echo  $links . "<br/>";
        }
    }

and return some link

download|

http://www.filesonic.com/file/24394419/1851684883.rar

http://depositfiles.com/files/g6wawevha

Please help me fix it

+2  A: 

Two problems:

for ($i; $i <= count($download); $i++) {

 // You are re-initializing $return in the loop..overwriting it.
  $return = "download|";  

Just move the initilization outside the loop as:

$return = "download|";
for ($i; $i <= count($download); $i++) {

Also you should not use <= in:

for ($i; $i <=count($download)

it should be just <. This is because in an array of size N, N is not a valid index. The valid indices are 0 to N-1.

Also ereg family of function are deprecated as of 5.3.0 so its better you stop using them. You can use preg_match instead.

if (!eregi("avaxhome.ws|pixhost.info", $links))

can be written using preg_match as:

if (!preg_match("/avaxhome\.ws|pixhost\.info/i", $links))

Also note that the . in the regex needs to be escaped to treat it as a literal period.

Working link

codaddict
A: 

Try using php's preg_match() instead of ereg()

http://www.php.net/manual/en/function.preg-match.php

etbal