Location: PHPKode > scripts > Better Array Storage > better-array-storage/example.php
###################################################################################################
###################################################################################################

$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>";
Return current item: Better Array Storage