Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$results = array();
if (!empty($html)) {
$div_class = $title = "";
$i = 0;
foreach ($html->find(".review-container") as $div_class) {
//Extract the review title
foreach ($div_class->find(".title") as $title) {
$results[$i]['title'] = $title->plaintext;
}
//Extract the number of star ratings
foreach ($div_class->find(".ipl-ratings-bar") as $ratings) {
$results[$i]['ratings'] = $ratings->plaintext;
}
//Extract the review content
foreach ($div_class->find('div[class=text show-more__control]') as $description) {
$content = html_entity_decode($description->plaintext);
$content = preg_replace('/\'/', "", $content);
$results[$i]['description'] = html_entity_decode($content);
}
$i++;
}
}
print_r($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment