Well I Need help in fetching a part of some external code For example <div class="test">Some text here</div> i want to fetch the Some text here part only How i can i do this please help me with a small code Thanks
Here you go just change the $fetchedata to grab data from a website. <?php $fetchedata = '<div class="test">Some text here</div>'; preg_match('/<div class="test">(.*?)<\/div>/is', $fetchedata, $matches); echo $matches[1]; ?> PHP:
So ideally you probably would do and change <div class="test">(.*?)<\/div> Code (markup): to the code you want to grab and put (.*?) in the place of the information you want to grab. hope you understand . <?php $fetchedata = file_get_contents("http://website.com"); preg_match('/<div class="test">(.*?)<\/div>/is', $fetchedata, $matches); echo $matches[1]; ?> PHP: