Hello,
If i have a HTML code like that
Code HTML4Strict:<div class="profile"> <h1>TOM</h1> <h2><a href="http://www.domain.com" title="Tom Site">Tom Site</a> </h2> <div><span class="about">About Tom</span></div> </div> <div class="profile"> <h1>Mark</h1> <h2><a href="http://www.domain.com" title="Mark Site">Mark Site</a> </h2> <div><span class="about">About Mark</span></div> </div> <div class="profile"> <h1>David/h1> <h2><a href="http://www.domain.com" title="David Site">David Site</a> </h2> <div><span class="about">About David</span></div> </div>
And i want to to extract or grab some information like:
Code:TOM Tom Site About Tom Mark Mark Site About Mark David David Site About DavidCode PHP:<?php $html=' <div class="profile"> <h1>TOM</h1> <h2><a href="http://www.domain.com" title="Tom Site">Tom Site</a> </h2> <div><span class="about">About Tom</span></div> </div> <div class="profile"> <h1>Mark</h1> <h2><a href="http://www.domain.com" title="Mark Site">Mark Site</a> </h2> <div><span class="about">About Mark</span></div> </div> <div class="profile"> <h1>David/h1> <h2><a href="http://www.domain.com" title="David Site">David Site</a> </h2> <div><span class="about">About David</span></div> </div>'; preg_match_all( '/<div class="profile">.*?<h1>(.*?)<\/h1>/s', $html, $name, PREG_SET_ORDER ); foreach ($name as $val) { echo $val[1] . "<br>"; } ?>
i tried this code and i got the names only like
Now how i get all information in one time?Code:TOM Mark David
Thank You


Reply With Quote






Bookmarks