PHP Classes

File: ar_example.php

Recommend this page to a friend!
  Classes of Khaled Al-Shamaa   ArZipStr   ar_example.php   Download  
File: ar_example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ArZipStr
Compress text using letter frequency for its idiom
Author: By
Last change:
Date: 17 years ago
Size: 2,138 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=windows-1256" />
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<title>Arabic Text Compressor</title>
</head>

<body>

<center>
<div style="width: 80%; position:absolute; left:10%; top:0%; z-index:1">
<br />
<div class="tabArea" align="center">
  <a class="tab" href="ar_example.php">Arabic Example</a>
  <a class="tab" href="en_example.php">English Example</a>
  <a class="tab" href="fr_example.php">French Example</a>
  <a class="tab" href="gr_example.php">German Example</a>
  <a class="tab" href="it_example.php">Italian Example</a>
  <a class="tab" href="sp_example.php">Spanish Example</a>
  <a class="tab" href="about.html">About</a>
</div>

<div class="Paragraph">
<?php
   
include('ArZipStr.class.php');
   
$obj = new ArZipStr();

   
$file = 'ar_example.txt';
   
$fh = fopen($file, 'r');
   
$str = fread($fh, filesize($file));
   
fclose($fh);

   
$zip = $obj->compress($str);

   
$before = strlen($str);
   
$after = strlen($zip);
   
$rate = round($after*100/$before);

    echo
"String size before was: $before Byte<br>";
    echo
"Compressed string size after is: $after Byte<br>";
    echo
"Rate $rate %<hr>";

   
$str = $obj->decompress($zip);

   
$word = 'الدول';
    if(
$obj->search($zip, $word)){
        echo
"Search for $word in zipped string and find it<hr>";
    }else{
        echo
"Search for $word in zipped string and do not find it<hr>";
    }

   
$len = $obj->length($zip);
    echo
"Original length of zipped string is $len Byte<hr>";
?>
<div dir="rtl" align="justify">
<?=nl2br($str); ?>
</div>

</div>
</center>
          <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
          </script>
          <script type="text/javascript">
          _uacct = "UA-1268287-1";
          urchinTracker();
          </script>
</body>
</html>