0
我有一個PHP循環,我希望索引($ i)從2開始計算,而不是從標準0開始計算。我如何實現目標?我試過$i=2;
,但不幸的是,似乎沒有工作。PHP:如何讓我的計數器從2開始計數而不是從0
任何人都可以幫忙嗎?這是我的循環:
$crawler->filter('div#product > div.row > div.span6 > div.thumbs > div.image a')->slice(1, 5)->each(function($node, $i) use(&$local, $lowertitle){
$filename = "images/galatea" . $lowertitle . $i . ".jpg";
$imageurl = $node->attr('href');
$theurl = substr($imageurl, 2);
copy('http://'.$theurl, $filename);
$imagesarray = $local['images'][] = $filename;
});
任何人請嗎? :(
你想循環閉合嗎? – wiesson
你能告訴我們你在哪裏給$ i賦值嗎? – SGR
@wiesson對不起,我不知道你的意思。我的目標只是讓我的$我從2開始計數,現在從0開始。所以,而不是0-1-2-3我想要2-3-4-6 –