I have some data that I have extracted, stripped out unneeded characters
and I was wondering if somehow I could define the rest of it as an array.
I am using PHP v 5.6.25
The stripped out data consist of 5 rows and each row contains 7 cells.
My first thought was grab each <tr></tr> section, finding the position of first <td> and then it's corresponding ending </td> and looping thru each <td> cell.
I would save the position of the previous ending </td> so be starting point of next cycle.
But I was wondering if I could define the <td></td> cells as an array - would be a heck of alot easier to extract the data
Below is what a section looks like and it is the same thru out table.
Maybe use eplode function first to redefine as an array ??
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Just one comment - be wary of trying to extract data from HTML, especially from traditional HTML tables. If you don't control the content already, then any change in the HTML code (even whitespace) could end up breaking your code. HTML is intentionally not very strict, so it's dangerous to try and use HTML structures as if they were reliable data structures.
You can help avoid this a little by using an HTML parser like simplehtmldom but if the owner of the content ever decides to just stop using traditional tables and switch to div-based tables, then that will also break your code. Whenever possible, you should try to see if you can get the data from an API instead of extracting it from HTML. An API is far more likely to stay reliable and give you very organized data that doesn't require you to manually parse it.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
You can help avoid this a little by using an HTML parser like simplehtmldom but if the owner of the content ever decides to just stop using traditional tables and switch to div-based tables, then that will also break your code. Whenever possible, you should try to see if you can get the data from an API instead of extracting it from HTML. An API is far more likely to stay reliable and give you very organized data that doesn't require you to manually parse it.