PHP Classes

File: ExtractTextExample.php

Recommend this page to a friend!
  Classes of Keith Hall   Extract Text Between Long Tags   ExtractTextExample.php   Download  
File: ExtractTextExample.php
Role: Example script
Content type: text/plain
Description: Usage example of the class
Class: Extract Text Between Long Tags
Extract data between two HTML tags
Author: By
Last change:
Date: 16 years ago
Size: 688 bytes


Class file image Download

    * Load the class


    * Initialize the class

$ext = new ExtractTextBetweenTags();

    * Make up some text

$text = <<<EOT
<h3 class="toggler atStart">Section Title 1</h3>
<div class="element atStart">Section One content goes here.</div><!-- elementAtStart -->

$header = $ext->extract($text,'<h3 class="toggler atStart">','</h3>');

// returns "Section Title 1"

$body = $ext->extract($text,'<div class="element atStart">','</div><!-- elementAtStart -->');

// returns "Section One content goes here."