PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Philipp Strazny  >  PHP String Diff Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: usage examples: English, Chinese, Russian, Thai characters
Class: PHP String Diff Class
Compare and find differences between two strings
Author: By
Last change:
Date: 2 years ago
Size: 2,413 bytes
 

Contents

Class file image Download
<html>
<body>
<?php
include('StringDiff.php');
print
StringDiff::getCSS();
$a = 'This is a string.';
$b = 'This would be another string.';
print
'<table>';
print
'<tr><td colspan=2>English characters:</td></tr>';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Chinese characters:</td></tr>';
$a = '油炸食品吃一月 损伤类似患肝炎';
$b = '油炸还会吃一月 损伤类似患肝炎还会';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Russian characters:</td></tr>';
$a = 'Неизвестные ограбили банк на Кутузовском проспекте Москвы ';
$b = 'Неизвестные орабили банк В Техасе';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Thai characters:</td></tr>';
$a = 'เดิมพันเก้าอี้ \'ผู้ว่าฯ กทม.\' ใครจะ \'สูญพันธุ์\' หรือ \'ค้านยาว\'';
$b = 'เดิมพันเก้าอี้ \'ผู้ว่าฯ .\' ใครจะ \'สูญพันธุ์\' หรือ \'ค้าสูญนยาว\'';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'</table>';


?>
</body>
</html>