PHP代码:
$file = file_get_contents('example.com/index/');
$array = array();
preg_match_all('!href=\\"(/img/[0-9]+.jpg)\\"!u', $file, $array);
$results = array_unique($array[1]);
foreach ( $results as $value ) {
$value = 'imgaes.example.com/' . $value;
echo "$value\n"; // imgaes.example.com/838.jpg
}
var_dump($results); // 838.jpg
Run Code Online (Sandbox Code Playgroud)
错误在哪里?我尝试做一个小强人。我想这是所有细节。
通过引用分配值:
foreach ( $results as &$value ){
...
}
unset($value);
Run Code Online (Sandbox Code Playgroud)