PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Steve Marks   Labels   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Sample Use
Class: Labels
Output address labels in HTML, Word or PDF formats
Author: By
Last change:
Date: 13 years ago
Size: 1,505 bytes
 

Contents

Class file image Download
<?php

   
include("labels.php");

   
// Load the library
   
$labels = new Labels;

   
// Specify the format
   
$config['format'] = 'html';
   
// Specify the address layout, using HTML <br /> tags to determine line breaks
    // The elements listed here become the address array keys (see below)
   
$config['layout'] = "first_name last_name<br />address_1<br />address_2<br />town<br />county<br />postcode";
   
$labels->initialize($config);

   
// List the addresses to used on the labels
    // Notice how the array keys correpond to the 'layout' element above
   
$addresses = array(
            array(
               
'first_name'=>'Steve',
               
'last_name'=>'Marks',
               
'address_1'=>'22 Sweet Avenue',
               
'address_2'=>'Mardi Tres',
               
'town'=>'Cheltenham',
               
'postcode'=>'NY6 6TR'
           
),
            array(
               
'first_name'=>'Bobbie',
               
'last_name'=>'Marley',
               
'address_1'=>'132 Reggae Lane',
               
'address_2'=>'East Hunting',
               
'town'=>'Northampton',
               
'postcode'=>'NN2 5TR'
           
),
            array(
               
'first_name'=>'James',
               
'last_name'=>'Shack',
               
'address_1'=>'23 Leapord Road',
               
'address_2'=>'Oaklingbury',
               
'town'=>'Cambridge',
               
'postcode'=>'CB4 7YT'
           
)
    );

   
// Output the labels
   
$labels->output($addresses);
   
?>