Skip to content
Advertisement

How to extract sub data out of arrays

I am using SIMPLE HTML DOM Scraper in PHP trying to get some statistics for various sports teams

index.php

JavaScript

Returns:

JavaScript

What im trying to get out of this is the team, followed by stats, for example index 0 would almost have 5 sub array indexs.

JavaScript

You can see there are multiple elements in the main array where I would need to do this. What is the best way, or should I be doing it a different way with the scraper?

Advertisement

Answer

Get the ->children() which would be the td‘s then loop over them to get ->text(), could use a foreach or array_map etc.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement