“preg_replace()”无法正常工作。

I've a text file that I extracted all the domain addresses strting with http:// now I want to replace all the http://. in my matches array with "" but nothing is happening im not even getting an an error

$list = file_get_contents( 'file.txt' );
preg_match_all( "/http:\/\/.([a-z]{1,24}).([a-z^0-9-]{1,23}).([a-z]{1,3})/", $list, $matches );

for ($i=0; $i>=50; $i++) {
    $pattern = array();
    $replacement = array();
    $pattern[0][$i] = "/http:\/\/.[w-w]{1,3}/";
    $replacement[0][$i] = '';

    preg_replace( $pattern[0][$i], $replacement[0][$i], $matches[0][$i] );
}

print_r($matches);

Your loop never runs because 0 >= 50 yields false. That said, what you're looking for is a map operation:

$matches = array_map(function($match) {
    return preg_replace('~^http://w{1,3}~', '', $match);
}, $matches[0]);
print_r($matches);

preg_match_all has also problem. The period in regular expression matches any character.

$list = file_get_contents( 'file.txt' );
preg_match_all( "/http:\/\/([a-z]{1,24})\.([a-z^0-9-]{1,23})\.([a-z]{1,3})/", $list, $matches );

$pattern = "/http:\/\/(.[w-w]{1,3})/";
$replacement = '$1';
$matches[0] = preg_replace( $pattern, $replacement, $matches[0] );

print_r($matches);