PHP find and get value based on another one from HTML table parsed file

By | July 12, 2018

I am using PHP Simple HTML DOM Parser for my project.

I am trying to find specific data and echo it after I parse my .php file from a URL Website which contains data inside HTML table element, example is below:

<table class="example">
     Heading #1
     <p>Description of heading #1 here ...</p>
   <td>Example of data #1</td>
     Heading #2
     <p>Description of heading #2 here ...</p>
   <td>Example of data #2</td>

My question:

How can I get value “Example of data #1” from the second TD cell element in first TR row element by knowing that the first TD cell in the same TR row contains value “Heading #1 …” from this kind of a table?

I have parsed URL, now I need to find value based on the other value which is next to it.

Should I use some regex and make some pattern for that? strpos() and array?


Leave a Reply

Your email address will not be published. Required fields are marked *