PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Bogdan Zarchievici   Better Array Storage   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Better Array Storage
Serialized arrays into compressed data
Author: By
Last change:
Date: 19 years ago
Size: 3,719 bytes
 

Contents

Class file image Download
###################################################################################################
###################################################################################################

$array_storage = new array_storage();

###################################################################################################
## UNI-DIMENSIONAL ARRAY ##########################################################################
###################################################################################################

$array=array(1=>'variable1',2=>'variable2',3=>'variable3',4=>'variable4',5=>'variable5',6=>'variable6',7=>'variable7',8=>'variable8',9=>'variable9');

echo "<table width=\"100%\"><tr><td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Uni-Dimensional Array:<br><br>";
print_r($array); echo "<br>";
echo "</pre>";
echo "</td>";

echo "<td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Compressed Array:<br><br>";
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime;
$compressed=$array_storage->compress($array);
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime);
print_r($compressed);
echo "<br><br>"; echo "Compressed in ".$totaltime." seconds"; echo "<br>";
echo "</pre>";
echo "</td>";

echo "<td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Decompressed Array:<br><br>";
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime;
$decompressed=$array_storage->decompress($compressed);
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime);
print_r($decompressed);
echo "<br><br>"; echo "Decompressed in ".$totaltime." seconds"; echo "<br>";
echo "</pre>";
echo "</td>";
echo "</tr></table>";
echo "<hr>";

###################################################################################################
## MULTI-DIMENSIONAL ARRAY ########################################################################
###################################################################################################

$array=array(array('1','2',3),array('1','2',3),array('1','2',3));

echo "<table width=\"100%\"><tr><td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Multi-Dimensional Array:<br><br>";
print_r($array); echo "<br>";
echo "</pre>";
echo "</td>";

echo "<td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Compressed Array:<br><br>";
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime;
$compressed=$array_storage->compress($array);
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime);
print_r($compressed);
echo "<br><br>"; echo "Compressed in ".$totaltime." seconds"; echo "<br>";
echo "</pre>";
echo "</td>";

echo "<td valign=\"top\" style=\"padding-right: 20\">";
echo "<pre>";
echo "Decompressed Array:<br><br>";
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime;
$decompressed=$array_storage->decompress($compressed);
$mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime);
print_r($decompressed);
echo "<br><br>"; echo "Decompressed in ".$totaltime." seconds"; echo "<br>";
echo "</pre>";
echo "</td>";
echo "</tr></table>";
echo "<hr>";