Autor | Zpráva | ||
---|---|---|---|
Taps Profil |
#1 · Zasláno: 3. 9. 2022, 08:09:09
Zdravím, pomocí simple_html_dom.php procházím rekurzivně odkazy na webu a na základě toho bych potřeboval vytvořit vícerozměrné pole s potomky. Mohl by mi prosím někdo poradit jak na to? Níže přikládám současný kod. Děkuji
<? $web = file_get_html('url adresa'); function recursive($html, $depth, $maxDepth) { foreach ($html->find('.seznam') as $list) { if ($depth <= $maxDepth) { foreach ($list->find('p') as $index => $p) { echo $p->plaintext . '<br>'; foreach ($p->find('a') as $a) { recursive(file_get_html($a->href), $depth + 1, $maxDepth); $index++; } } } } } $x = recursive($web, 1, 3); ?> |
||
Keeehi Profil |
#2 · Zasláno: 3. 9. 2022, 08:53:14
function recursive($html, $depth, $maxDepth) { $r = []; foreach ($html->find('.seznam') as $list) { if ($depth <= $maxDepth) { foreach ($list->find('p') as $index => $p) { echo $p->plaintext . '<br>'; foreach ($p->find('a') as $a) { $r[$a->href] = recursive(file_get_html($a->href), $depth + 1, $maxDepth); $index++; } } return $r; } } } Nevím k čemu tam máš to $index++ , nic to nedělá. Ale nechal jsem to tam.
|
||
Taps Profil |
#3 · Zasláno: 3. 9. 2022, 09:09:00
Keeehi:
Moc díky, indexx+ byl jen pozůstatek při testování
|
||
Časová prodleva: 3 roky
|
0