【发布时间】:2011-12-30 02:17:36
【问题描述】:
这给了我一个错误,例如“注意:未定义的偏移量:第 12 行的 \index.php 中的 0”。
$arr = array('a', 'b', 'c', 'd');
$i=0;
while($i<=3){
foreach($arr as $value){
//get data
$content = file_get_contents('http://www.example.com/$value');
preg_match("^ y: ....^", $content, $match);
$string = $match[$i];
$i++;
echo $value;
echo $string;
}
}
【问题讨论】:
-
$match与您使用它的方式不同——它包含子模式匹配。我建议您在修改代码之前仔细阅读PCRE documentation。 -
你不需要 while 循环
标签: php preg-match undefined offset