답변
의 변수를 가져올 당신은 배열
require_once 'simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('http://www.example.com/?search=movies');
$videos=array();
$ret = $html->find('span.video-title');
$counter=0;
foreach($ret as $elements) {
foreach($elements->find('a') as $link) {
$id = $link->href;
$videos[$counter]['ID']=$id;
$counter++;
}
}
$counter=0;
foreach($html->find('span.video-title') as $titlu) {
$title = $titlu->find('a', 0)->innertext;
$videos[$counter]['title']=$title;
$counter++;
}
$counter=0;
foreach($html->find('span.video-duration') as $durata) {
$time = $durata->outertext;
$videos[$counter]['time']=$time;
$counter++;
}
$counter=0;
foreach($html->find('img.lazy') as $imagine) {
$images = $imagine->getAttribute('data-src');
$videos[$counter]['images']=$images;
$counter++;
}
echo $id;
echo $title;
echo $time;
echo $images;
구문 분석 오류 : 구문 오류, 38 번째 줄에있는 C : \ xampp \ htdocs \ file.php의 예기치 않은 '$ counter'(T_VARIABLE)이 마지막 $ counter ++입니다. – user3356954
가 추가되었습니다. 이제 semiclon이 누락되었습니다. – cirtrus
이 코드는 약간의 품질을 제공합니다. @citrus 옆에 이름을 올리는 것을 거부하지 않았습니까? – hakre
당신은 각 문자열 (HTML)를 연결할한다의 비디오 데이터를 저장해야합니다. 당신은 모든 결과를 얻을 수 있도록 ... 코드는 [PHP는 간단한 HTML DOM img와 사용자 정의 데이터]의
require_once 'simple_html_dom.php';
$html = new simple_html_dom();
$html->load_file('http://www.example.com/?search=movies');
$id = "";
$title = "";
$images = "";
$time = "";
$ret = $html->find('span.video-title');
foreach($ret as $elements) {
foreach($elements->find('a') as $link) {
$id .= $link->href;
}
}
foreach($html->find('span.video-title') as $titlu) {
$title .= $titlu->find('a', 0)->innertext;
}
foreach($html->find('span.video-duration') as $durata) {
$time. = $durata->outertext;
}
foreach($html->find('img.lazy') as $imagine) {
$images .= $imagine->getAttribute('data-src');
}
echo $id;
echo $title;
echo $time;
echo $images;
가능한 중복 (http://stackoverflow.com/questions/27677099/php-simple 같이해야한다 -html-dom-img-custom-data) – AeroX
이 웹 사이트에서 디버깅 요청을 게시하지 마십시오. 웹 사이트는 프로그래밍 관련 질문을위한 것입니다. 실제 코드를 잘라내어 붙여 넣는 대신 처음부터 문제를 설명하는 데 필요한 코드를 사용하여 예제를 작성하십시오. 단, 지금까지 해당 주제에 대한 기존 답변을 찾을 수없는 경우에만 가능합니다. – hakre