답변
의 변수를 가져올 당신은 배열
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;
- 1. 간단한 html dom은 javascript에서 값을 얻습니다
- 2. 왜이 간단한 DOM은 작동하지 않습니까?
- 3. 간단한 HTML DOM은 encore에서 HTML 표시를 지원하지 않습니다.
- 4. 간단한 html dom은 테이블을 구분 기호로 사용하여 html을 청크로 나눕니다.
- 5. 간단한 HTML DOM은 단 하나의 요소 만 가져옵니다.
- 6. array_unique()는 PHP는 간단한 HTML DOM에
- 7. 원격 서버에서 variabile $ _global 사용
- 8. DOM은 순서가 잘못된 HTML 요소를 만듭니다.
- 9. DOM은 요소로 채워 사전 나의 HTML 소스
- 10. jQuery를 삽입 HTML 문자열 대신 DOM은
- 11. HTML DOM은 어디에서 시작합니까? 창문? 문서? document.defaultView?
- 12. html DOM은 가장 큰 이미지 만 긁는다
- 13. HTML PHP는
- 14. PHP는 간단한 변수를 저장합니다
- 15. PHP는 : 간단한 템플릿 엔진
- 16. 간단한 jQuery를 PHP는 JSON
- 17. 간단한 PHP는 .. 작동하지 않습니다는 ... 흠은
- 18. DOM은 어떻게 파싱됩니까?
- 19. XML DOM은
- 20. PHP의 DOM은
- 21. 에는 DOM은
- 22. 테스트 DOM은
- 23. 업데이트 DOM은
- 24. DOM은 노드를 어떻게 표현합니까?
- 25. 자바 스크립트 DOM은
- 26. HTML PHP는 포맷
- 27. 다운로드 PHP는 HTML 파일
- 28. PHP는 HTML 태그를 대체합니다.
- 29. PHP는 HTML 파서 성능
- 30. 워드 프레스 PHP는 HTML
가능한 중복 (http://stackoverflow.com/questions/27677099/php-simple 같이해야한다 -html-dom-img-custom-data) – AeroX
이 웹 사이트에서 디버깅 요청을 게시하지 마십시오. 웹 사이트는 프로그래밍 관련 질문을위한 것입니다. 실제 코드를 잘라내어 붙여 넣는 대신 처음부터 문제를 설명하는 데 필요한 코드를 사용하여 예제를 작성하십시오. 단, 지금까지 해당 주제에 대한 기존 답변을 찾을 수없는 경우에만 가능합니다. – hakre