Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Get all HTML list element using Simple HTML Dom

Currently I am working on a project which requires me to parse some data from an alternative website, and I'm having some issues (note I am very new to PHP coding.)

Here's the code I am using below + the content it returns.

$dl = $html2->find('ol.tracklist',0);
print $dl = $dl->outertext;

The above code returns the data for what we're trying to get, it's below but extremely messy provided you would like to see click here.

However, when I put this in a foreach, it only returns one of the a href attributes at a time.

foreach($html2->find('ol.tracklist') as $li) 
{
    $title = $li->find('a',0);
    print $title;
}

What can I do so that it returns all of the a href elements from the example code above?

NOTE: I am using simple_html_dom.php for this.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Based on the markup, just point directly to it, just get it list then point to its anchor:

foreach ($html2->find('ol.tracklist li') as $li) {
    $anchor = $li->find('ul li a', 0);
    echo $anchor->href; // and other attributes
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!