PHP Classes

File: demo/buffer_demo_1.php

Recommend this page to a friend!
  Classes of Roger Baklund   Buffer tree   demo/buffer_demo_1.php   Download  
File: demo/buffer_demo_1.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Buffer tree
Manage ordered collections of data items
Author: By
Last change: Update of demo/buffer_demo_1.php
Date: 8 months ago
Size: 709 bytes
 

Contents

Class file image Download
<?php

include '../buffer.class.php';

function
ColSet($sep="\t"){ return new buffer('ColSet',$sep); }
function
RowSet($sep="\n"){ return new buffer('RowSet',$sep); }

function
Compose($datarow,$idx,$extra) {
  list(
$R,$C) = $extra; # rows/cols
 
$C->replace($datarow);
 
$R->append(clone $C); # append clone to rows
}

$data = array(
  array(
1,2,2,1,3,4,5,3,2),
  array(
2,1,2,1,2,3,4,3,3),
  array(
1,3,1,2,3,2,2,2,1),
  array(
3,2,2,3,1,3,2,1,1),
  array(
2,2,3,3,4,1,4,1,2)
);

$R = RowSet(); # collection of rows

array_walk($data,'Compose',array($R,ColSet()));
echo
"$R\n\n";

array_walk($R->content,
 
create_function('$C','$C->separator = ";";'));
echo
"$R\n\n";

$R->separator = '|';
echo
"$R\n\n";

?>