html - PHP file_get_contents get all contents from multiple div by class name -


i want grab what's new text play store whatsapp. trying below code, , it's working well.

<?php $url = 'https://play.google.com/store/apps/details?id=com.whatsapp&hl=en'; $content = file_get_contents($url); $first_step = explode( '<div class="recent-change">' , $content ); $second_step = explode("</div>" , $first_step[1] ); echo $second_step[0]; ?> 

the issue that, code show text first recent-change div class. has multiple divs recent-change class name. how content it?

as suggested in comments have use dom content. if want display text containing recent-change class. can use loop. providing solution on same way using

$url = 'https://play.google.com/store/apps/details?id=com.whatsapp&hl=en'; $content = file_get_contents($url); $first_step = explode( '<div class="recent-change">' , $content ); foreach ($first_step $key => $value) {   if($key > 0)   {     $second_step = explode("</div>" , $value );     echo $second_step[0];         echo "<br>";   } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -