Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- /** Membuat dom baru**/
- $dom = new domDocument;
- $dom->preserveWhiteSpace = false;
- // memuat file data.html
- $dom -> loadHTMLFile("data.html");
- // mengambil id dari tabel
- $elm = $dom->getElementById('tabel2');
- echo "</br>";
- foreach ($elm->getElementsByTagName('tr') as $data) {
- $d = ($dom->saveHTML($data));
- $d = rip_tags($d);
- $txt = explode(' ', $d);
- echo "Designation : ".$txt[0].'<br/>Manager:'.$txt[1]." <br/>Team:".$txt[2];
- echo "<hr/>";
- }
- function rip_tags($string) {
- // ----- menghapus tag html -----
- $string = preg_replace ('/<[^>]*>/', ' ', $string);
- // ----- menghapus control characters -----
- $string = str_replace("\r", '', $string); // --- replace with empty space
- $string = str_replace("\n", ' ', $string); // --- replace with space
- $string = str_replace("\t", ' ', $string); // --- replace with space
- // ----- menghapus multiple spaces -----
- $string = trim(preg_replace('/ {2,}/', ' ', $string));
- return $string;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement