이 코드의 끝에는 모든 배열에 모든 $ id를주고 추가하는 배열이 있습니다.루프의 끝에 배열에 추가
코드는 배열에서 15가되고 다음 15 개 항목으로 덮어 씁니다. 배열에 30 개의 항목이있는 코드의 끝에 배열을 만들 수 있기를 원합니다. 아래
내 코드 : 당신은 여기 $ idArray을 재정의하기 때문에
$idArray = array();
do {
$html = file_get_html($url);
parseItems($html, $dbh);
sleep_flush($chunks=1); // ADJUST LATER
}
while (!empty($html->find('span[class=load-more-message]', 0)));
$html->clear();
unset($html);
// -------------------------------------------------
function parseItems($html, $dbh) {
foreach($html->find('div.product-stamp-inner') as $content) {
$detail['itemid'] = filter_var($content->find('a.product-title-link', 0)->href, FILTER_SANITIZE_NUMBER_FLOAT);
$id = $detail['itemid'];
$idArray[] = $id; //Counting and adding items to an array
$detail['title'] = $content->find('span.title', 0)->plaintext;
$description = $detail['title'];
if (!tableExists($dbh, $id, $detail)) {
echo $id . " > " . $description . "> Table does not exist >";
createTable($dbh, $id, $description);
insertData($dbh, $id, $detail);
echo "<br>";
} else {
echo $id . " > " . $description . "> Table already exists >";
checkData($dbh, $id, $detail);
echo "<br>";
}
}
print_r($idArray);
}
'$ idArray'를 함수 정의 밖으로 끌어 와서 전역/세션으로 만들 수 있습니다. ariable. –