PHP Classes
elePHPant
Icontem

File: ExtractTextExample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 7 years ago
Size: 688 bytes
 

Contents

Class file image Download
<?php

   
/**
    * Load the class
    **/

   
require_once("ExtractTextBetweenTags.class.php");

   
/**
    * 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 -->
<!--sectionbreak-->
EOT;

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

   
// returns "Section Title 1"

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

   
// returns "Section One content goes here."


?>