This is a live demonstration sample application of the WiseLoop PHP Advanced String Classes software product.
WiseLoop PHP Advanced String Classes is the complete multi-byte and binary safe PHP string processing solution that enables you to:
validate input data types (alpha, numeric, date, IP, email, URL, hex), change case,
apply string effects (shorten, shuffle, scramble, reverse, make URL SEO friendly), generate passwords, generate GUIDs,
process and extract characters, words and sentences, compute statistics (word count, unique word count, char count),
numbers extraction, substring searching and replacing, padding, trimming, splitting, word wrapping, html processing,
encrypting, encoding, censoring, spell checking, spell auto correcting etc.
All the methods and classes have full support for any language character set or alphabet through a customizable configuration class.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString("The quick brown fox jumped over the lazy dog.");
echo $my->shorten(10) . '<br/>';
echo $my->shorten(10, 0) . '<br/>';
echo $my->shorten(10, 0.1) . '<br/>';
echo $my->shorten(10, 0.5) . '<br/>';
echo $my->shorten(10, 0.7) . '<br/>';
echo $my->shorten(10, 1, ' ... <a href="#">[Read More]</a>');
?>Result:
The q ... dog.
... lazy dog.
T ... lazy dog.
The q ... dog.
The qui ... og.
The quick ... [Read More]
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString("The dog said: screw you stupid fox!");
echo $my->censor() . '<br/>';
echo $my->censor(false, '*') . '<br/>';
echo $my->censorWords() . '<br/>';
echo $my->censorWords(array('screw', 'stupid'));
?>Result:
Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx!
***********************************
Txe dog said: sxxxw you stupid fox!
The dog said: sxxxw you sxxxxd fox!
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString("The quick brown fox jumped over the lazy dog.");
echo $my->scramble() . '<br/>';
echo $my->reverse() . '<br/>';
echo $my->shuffle() . '<br/>';
echo $my->seoFriendly() . '<br/>';
?>Result:
The qucik borwn fox juempd over the lazy dog.
.god yzal eht revo depmuj xof nworb kciuq ehT
vgu firodecdrow. j zkmuybhptxoqTe eneo hla
the-quick-brown-fox-jumped-over-the-lazy-dog
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString("The fox replied back to the dog: I'm very sorry my dear dog!");
echo $my->emphasize(array('the dog', 'fox')) . '<br/>';
echo $my->emphasize(array('the dog', 'fox'), true, '<em>', '<b>') . '<br/>';
?>Result:
The fox replied back to the dog: I'm very sorry my dear dog!
The fox replied back to the dog: I'm very sorry my dear dog!
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my . '<br/>';
$my1 = $my->copy();
echo $my1->get() . '<br/>';
?>Result:
The quick fox jumped over the lazy dog.
The quick fox jumped over the lazy dog.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString();
//$my->load('http://a-site-url.com/the-page.html');
//$my->load('path-to-a-local-file.txt');
?>Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('infoemail.com');
echo $my->isEmail() ? $my->append(' is a valid email address') : $my->append(' is an invalid email address'); echo '<br/>';
$my = new wlString('info@emailcom');
echo $my->isEmail() ? $my->append(' is a valid email address') : $my->append(' is an invalid email address'); echo '<br/>';
$my = new wlString('info@email.com');
echo $my->isEmail() ? $my->append(' is a valid email address') : $my->append(' is an invalid email address'); echo '<br/>';
?>Result:
infoemail.com is an invalid email address
info@emailcom is an invalid email address
info@email.com is a valid email address
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('123456');
echo $my->isHexColor() ? $my->append(' is hex color') : $my->append(' is not hex color'); echo '<br/>';
$my->set('#123456');
echo $my->isHexColor() ? $my->append(' is hex color') : $my->append(' is not hex color'); echo '<br/>';
$my->set('#F3D4AE');
echo $my->isHexColor() ? $my->append(' is hex color') : $my->append(' is not hex color'); echo '<br/>';
$my->set('#F3K4AE');
echo $my->isHexColor() ? $my->append(' is hex color') : $my->append(' is not hex color'); echo '<br/>';
?>Result:
123456 is not hex color
#123456 is hex color
#F3D4AE is hex color
#F3K4AE is not hex color
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('13/04/2011');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('04/13/2011');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('2011/04/13');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('2011-04-13');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('2011-Apr-13');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('13-April 2011');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('13Apr11');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('April 13st, 2011');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('Apr-13-11');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
$my = new wlString('11-Apr-13');
echo $my->isDate() ? $my->append(' is a valid date') : $my->append(' is an invalid date'); echo '<br/>';
?>Result:
13/04/2011 is an invalid date
04/13/2011 is a valid date
2011/04/13 is a valid date
2011-04-13 is a valid date
2011-Apr-13 is a valid date
13-April 2011 is a valid date
13Apr11 is a valid date
April 13st, 2011 is a valid date
Apr-13-11 is a valid date
11-Apr-13 is a valid date
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('192');
echo $my->isIp() ? $my->append(' is a valid IP address') : $my->append(' is an invalid IP address'); echo '<br/>';
$my = new wlString('192.168');
echo $my->isIp() ? $my->append(' is a valid IP address') : $my->append(' is an invalid IP address'); echo '<br/>';
$my = new wlString('192.168.100.');
echo $my->isIp() ? $my->append(' is a valid IP address') : $my->append(' is an invalid IP address'); echo '<br/>';
$my = new wlString('192.168.1002.101');
echo $my->isIp() ? $my->append(' is a valid IP address') : $my->append(' is an invalid IP address'); echo '<br/>';
$my = new wlString('192.168.100.101');
echo $my->isIp() ? $my->append(' is a valid IP address') : $my->append(' is an invalid IP address'); echo '<br/>';
?>Result:
192 is an invalid IP address
192.168 is an invalid IP address
192.168.100. is an invalid IP address
192.168.1002.101 is an invalid IP address
192.168.100.101 is a valid IP address
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog');
echo 'Capital: '; echo $my->isCapitalCase() ? 'yes' : 'no'; echo '<br/>';
echo 'Lower: '; echo $my->isLowerCase() ? 'yes' : 'no'; echo '<br/>';
echo 'Upper: '; echo $my->isUpperCase() ? 'yes' : 'no'; echo '<br/>';
echo 'Sentence: '; echo $my->isSentenceCase() ? 'yes' : 'no'; echo '<br/>';
echo 'Empty: '; echo $my->isEmpty() ? 'yes' : 'no'; echo '<br/>';
echo 'White: '; echo $my->isWhite() ? 'yes' : 'no'; echo '<br/>';
echo '<br/>';
$my = new wlString(' ');
echo 'Empty: '; echo $my->isEmpty() ? 'yes' : 'no'; echo '<br/>';
echo 'White: '; echo $my->isWhite() ? 'yes' : 'no'; echo '<br/>';
?>Result:
Capital: yes
Lower: no
Upper: no
Sentence: no
Empty: no
White: no
Empty: no
White: yes
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('123456');
echo $my->isAlpha() ? $my->append(' is alpha') : $my->append(' is not alpha'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo '<br/>';
$my->set('Abc ');
echo $my->isAlpha() ? $my->append(' is alpha') : $my->append(' is not alpha'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo $my->inRange('Ab', 'cde') ? $my->append(' is between "Ab" and "cde"') : $my->append(' is not between "Ab" and "cde"'); echo '<br/>';
echo $my->inRange('Bet', 'Rex') ? $my->append(' is between "Bet" and "Rex"') : $my->append(' is not between "Bet" and "Rex"'); echo '<br/>';
echo '<br/>';
$my->set('Abc 123456');
echo $my->isAlpha() ? $my->append(' is alpha') : $my->append(' is not alpha'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo '<br/>';
$my->set('Abc 123456 #');
echo $my->isAlpha() ? $my->append(' is alpha') : $my->append(' is not alpha'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
?>Result:
123456 is not alpha
123456 is alphanumeric
Abc is alpha
Abc is alphanumeric
Abc is between "Ab" and "cde"
Abc is not between "Bet" and "Rex"
Abc 123456 is not alpha
Abc 123456 is alphanumeric
Abc 123456 # is not alpha
Abc 123456 # is not alphanumeric
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('123456');
echo $my->isNumeric() ? $my->append(' is numeric') : $my->append(' is not numeric'); echo '<br/>';
echo $my->isFloat() ? $my->append(' is float') : $my->append(' is not float'); echo '<br/>';
echo $my->isInteger() ? $my->append(' is integer') : $my->append(' is not integer'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo $my->inRange('10', '3445') ? $my->append(' is between 10 and 3445') : $my->append(' is not between 10 and 3445'); echo '<br/>';
echo $my->inRange('123455', '12345678') ? $my->append(' is between 123455 and 12345678') : $my->append(' is not between 123455 and 12345678'); echo '<br/>';
echo '<br/>';
$my->set('123456.35');
echo $my->isNumeric() ? $my->append(' is numeric') : $my->append(' is not numeric'); echo '<br/>';
echo $my->isFloat() ? $my->append(' is float') : $my->append(' is not float'); echo '<br/>';
echo $my->isInteger() ? $my->append(' is integer') : $my->append(' is not integer'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo $my->inRange('10', '3445') ? $my->append(' is between 10 and 3445') : $my->append(' is not between 10 and 3445'); echo '<br/>';
echo $my->inRange('123455', '12345678') ? $my->append(' is between 123455 and 12345678') : $my->append(' is not between 123455 and 12345678'); echo '<br/>';
echo '<br/>';
$my->set('Abc ');
echo $my->isNumeric() ? $my->append(' is numeric') : $my->append(' is not numeric'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo '<br/>';
$my->set('Abc 123456');
echo $my->isNumeric() ? $my->append(' is numeric') : $my->append(' is not numeric'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
echo '<br/>';
$my->set('Abc 123456 #');
echo $my->isNumeric() ? $my->append(' is numeric') : $my->append(' is not numeric'); echo '<br/>';
echo $my->isAlphaNumeric() ? $my->append(' is alphanumeric') : $my->append(' is not alphanumeric'); echo '<br/>';
?>Result:
123456 is numeric
123456 is float
123456 is integer
123456 is alphanumeric
123456 is not between 10 and 3445
123456 is between 123455 and 12345678
123456.35 is numeric
123456.35 is float
123456.35 is not integer
123456.35 is not alphanumeric
123456.35 is not between 10 and 3445
123456.35 is between 123455 and 12345678
Abc is not numeric
Abc is alphanumeric
Abc 123456 is not numeric
Abc 123456 is alphanumeric
Abc 123456 # is not numeric
Abc 123456 # is not alphanumeric
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('htp://www.wiseloop.com');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
$my = new wlString('www.wiseloop.com');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
$my = new wlString('http://wiseloop');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
$my = new wlString('http://wiseloop.');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
$my = new wlString('http://wiseloop.com');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
$my = new wlString('http://www.wiseloop.com');
echo $my->isUrl() ? $my->append(' is a valid url') : $my->append(' is an invalid url'); echo '<br/>';
?>Result:
htp://www.wiseloop.com is an invalid url
www.wiseloop.com is an invalid url
http://wiseloop is an invalid url
http://wiseloop. is an invalid url
http://wiseloop.com is a valid url
http://www.wiseloop.com is a valid url
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick, quick fox jumped over the lazy dog.');
echo $my->insert('red ', 17) . '<br/>';
echo $my->insert('red ', 17)->append(' The dog was sleeping.'). '<br/>';
echo $my->remove(4, 7) . '<br/>';
echo $my->substitute('quick', 'red'). '<br/>';
echo $my->substitute('quick', 'red', 1). '<br/>';
echo $my->replace(array('quick,', 'quick', 'fox'), array('furious,', 'fast', 'snail')). '<br/>';
?>Result:
The quick, quick red fox jumped over the lazy dog.
The quick, quick red fox jumped over the lazy dog. The dog was sleeping.
The quick fox jumped over the lazy dog.
The red, red fox jumped over the lazy dog.
The red, quick fox jumped over the lazy dog.
The furious, fast snail jumped over the lazy dog.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('the quick FOX jumped over the lazy DOG.');
echo $my->toLowerCase() . '<br/>';
echo $my->toUpperCase() . '<br/>';
echo $my->toCapitalCase() . '<br/>';
echo $my->toSentenceCase() . '<br/>';
echo $my->toRandomCase() . '<br/>';
echo $my->toRandomCase()->toCapitalCase() . '<br/>';
?>Result:
the quick fox jumped over the lazy dog.
THE QUICK FOX JUMPED OVER THE LAZY DOG.
The quick fox jumped over the lazy dog.
The Quick FOX Jumped Over The Lazy DOG.
ThE quIcK FOX jumPED OVeR The lAzy DOg.
The quick fox jumped over the lazy dog.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick, brown fox jumped over the lazy dog! The lazy doggy dog remained asleep.');
echo $my->chunkSplit()->htmlNl2Br() . '<br/>';
echo $my->chunkSplit(25)->htmlNl2Br() . '<br/>';
echo '<pre>' . print_r($my->split(25), true) . '</pre>';
echo '<pre>' . print_r($my->explode('!'), true) . '</pre>';
?>Result:
The quick, brown fox jumped over the lazy dog! The lazy doggy dog remained a
sleep.
The quick, brown fox jump
ed over the lazy dog! The
lazy doggy dog remained
asleep.
Array ( [0] => The quick, brown fox jump [1] => ed over the lazy dog! The [2] => lazy doggy dog remained [3] => asleep. )Array ( [0] => The quick, brown fox jumped over the lazy dog [1] => The lazy doggy dog remained asleep. )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick, brown fox jumped over the lazy dog! The lazy doggy dog remained asleep.');
echo '<pre>'. print_r($my->wordWrap(10), true) . '</pre>';
?>Result:
Array
(
[0] => The quick,
[1] => brown fox
[2] => jumped
[3] => over the
[4] => lazy dog!
[5] => The lazy
[6] => doggy dog
[7] => remained
[8] => asleep.
)
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString(' 123456789$% The quick fox jumped over the lazy dog. 123456789@#$ ');
echo $my->trimStart('1..9 %$') . '<br/>';
echo $my->trimEnd('1..9 @#$.') . '<br/>';
echo $my->trimBoth('1..9 @#$%.') . '<br/>';
echo $my->removeNonAlphaNumeric() . '<br/>';
echo $my->removeNonAlpha() . '<br/>';
echo $my->removeNonNumeric() . '<br/>';
?>Result:
The quick fox jumped over the lazy dog. 123456789@#$
123456789$% The quick fox jumped over the lazy dog
The quick fox jumped over the lazy dog
123456789 The quick fox jumped over the lazy dog 123456789
The quick fox jumped over the lazy dog
123456789123456789
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('the quick, brown fox jumped over the lazy dog');
echo $my->padLeft(50, '#')->htmlAppendBreak();
echo $my->padRight(50, '#')->htmlAppendBreak();
echo $my->padBoth(50, '#')->htmlAppendBreak();
echo $my->padLeft(50, '-')->padRight(60, '=')->htmlAppendBreak();
echo '<br/>';
echo $my->enclose('123 ', ' 456')->htmlAppendBreak();
echo $my->enclose('---| ')->htmlAppendBreak();
echo $my->enclose('(')->htmlAppendBreak();
echo $my->enclose('[')->htmlAppendBreak();
echo $my->enclose('{')->htmlAppendBreak();
echo $my->enclose('"')->htmlAppendBreak();
?>Result:
#####the quick, brown fox jumped over the lazy dog
the quick, brown fox jumped over the lazy dog#####
##the quick, brown fox jumped over the lazy dog###
-----the quick, brown fox jumped over the lazy dog==========
123 the quick, brown fox jumped over the lazy dog 456
---| the quick, brown fox jumped over the lazy dog |---
(the quick, brown fox jumped over the lazy dog)
[the quick, brown fox jumped over the lazy dog]
{the quick, brown fox jumped over the lazy dog}
"the quick, brown fox jumped over the lazy dog"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('I copied this 102500 file for 5437894 times.');
echo $my->append(' ')->repeat(3) . '<br/>';
echo $my->generatePassword() . '<br/>';
echo $my->generateGUID() . '<br/>';
echo '<pre>' . print_r($my->spellExtractedNumber(), true) . '</pre>';
echo '<pre>' . print_r($my->byteSizeExtractedNumber(), true) . '</pre>';
echo $my->spellExtractedNumber(0) . '<br/>';
echo $my->spellExtractedNumber(1) . '<br/>';
echo $my->byteSizeExtractedNumber(0) . '<br/>';
echo $my->spellNumbers() . '<br/>';
echo $my->spellNumbers(1)->byteSizeNumbers() . '<br/>';
?>Result:
I copied this 102500 file for 5437894 times. I copied this 102500 file for 5437894 times. I copied this 102500 file for 5437894 times.
3wnhe78y
6920989d6f4b8f5b6771d0270143ac75Array ( [0] => wlString Object ( [_s:private] => one hundred two thousand five hundred [_encoding:private] => ) [1] => wlString Object ( [_s:private] => five million four hundred thirty seven thousand eight hundred ninety four [_encoding:private] => ) )Array ( [0] => wlString Object ( [_s:private] => 100.10 KB [_encoding:private] => ) [1] => wlString Object ( [_s:private] => 5.19 MB [_encoding:private] => ) )one hundred two thousand five hundred
five million four hundred thirty seven thousand eight hundred ninety four
100.10 KB
I copied this one hundred two thousand five hundred file for five million four hundred thirty seven thousand eight hundred ninety four times.
I copied this 100.10 KB file for five million four hundred thirty seven thousand eight hundred ninety four times.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my->substring(0, 25)->append('.') . '<br/>';
echo $my->between('quick', 'the') . '<br/>';
echo $my->between('over') . '<br/>';
echo $my->between('the', 'dog', 'the') . '<br/>';
echo $my->intersect('The fox jumped into a hole.') . '<br/>';
echo $my->intersect(new wlString('The fox jumped into a hole.')) . '<br/>';
echo $my->intersectChars('The fox jumped into a hole.') . '<br/>';
echo $my->intersectWords('The fox jumped into a hole.') . '<br/>';
?>Result:
The quick fox jumped over.
fox jumped over
the lazy dog.
lazy
fox jumped
fox jumped
The ui fox jumped oe the la do.
The fox jumped
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my->firstIndex('not-found') . '<br/>';
echo $my->firstIndex('the') . '<br/>';
echo $my->firstIndex('the', 0, true) . '<br/>';
echo $my->lastIndex('the') . '<br/>';
?>Result:
0
26
26
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('This is my phone number: +0040123425893. You balance is: $1025.45');
echo '<pre>' . print_r($my->extractNumbers(), true). '</pre>';
?>Result:
Array
(
[0] => 0040123425893
[1] => 1025.45
)
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick, quick fox jumped 3.5 times over the lazy dog. The dog wasn\'t happy about it');
echo '<pre>' . print_r($my->words(), true). '</pre>';
echo '<pre>' . print_r($my->uniqueWords(), true). '</pre>';
echo '<pre>' . print_r($my->uniqueWords(true), true). '</pre>';
?>Result:
Array ( [0] => The [1] => quick [2] => quick [3] => fox [4] => jumped [5] => 3.5 [6] => times [7] => over [8] => the [9] => lazy [10] => dog [11] => The [12] => dog [13] => wasn't [14] => happy [15] => about [16] => it )Array ( [the] => 3 [quick] => 2 [fox] => 1 [jumped] => 1 [3.5] => 1 [times] => 1 [over] => 1 [lazy] => 1 [dog] => 2 [wasn't] => 1 [happy] => 1 [about] => 1 [it] => 1 )Array ( [The] => 2 [quick] => 2 [fox] => 1 [jumped] => 1 [3.5] => 1 [times] => 1 [over] => 1 [the] => 1 [lazy] => 1 [dog] => 2 [wasn't] => 1 [happy] => 1 [about] => 1 [it] => 1 )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my->char(2) . '<br/>';
echo '<pre>' . print_r($my->chars(), true). '</pre>';
echo '<pre>' . print_r($my->uniqueChars(), true). '</pre>';
echo '<pre>' . print_r($my->uniqueChars(true), true). '</pre>';
echo '<pre>' . print_r($my->ord(), true). '</pre>';
?>Result:
eArray ( [0] => T [1] => h [2] => e [3] => [4] => q [5] => u [6] => i [7] => c [8] => k [9] => [10] => f [11] => o [12] => x [13] => [14] => j [15] => u [16] => m [17] => p [18] => e [19] => d [20] => [21] => o [22] => v [23] => e [24] => r [25] => [26] => t [27] => h [28] => e [29] => [30] => l [31] => a [32] => z [33] => y [34] => [35] => d [36] => o [37] => g [38] => . )Array ( [t] => 2 [h] => 2 [e] => 4 [ ] => 7 [q] => 1 [u] => 2 [i] => 1 [c] => 1 [k] => 1 [f] => 1 [o] => 3 [x] => 1 [j] => 1 [m] => 1 [p] => 1 [d] => 2 [v] => 1 [r] => 1 [l] => 1 [a] => 1 [z] => 1 [y] => 1 [g] => 1 [.] => 1 )Array ( [T] => 1 [h] => 2 [e] => 4 [ ] => 7 [q] => 1 [u] => 2 [i] => 1 [c] => 1 [k] => 1 [f] => 1 [o] => 3 [x] => 1 [j] => 1 [m] => 1 [p] => 1 [d] => 2 [v] => 1 [r] => 1 [t] => 1 [l] => 1 [a] => 1 [z] => 1 [y] => 1 [g] => 1 [.] => 1 )Array ( [0] => 84 [1] => 104 [2] => 101 [3] => 32 [4] => 113 [5] => 117 [6] => 105 [7] => 99 [8] => 107 [9] => 32 [10] => 102 [11] => 111 [12] => 120 [13] => 32 [14] => 106 [15] => 117 [16] => 109 [17] => 112 [18] => 101 [19] => 100 [20] => 32 [21] => 111 [22] => 118 [23] => 101 [24] => 114 [25] => 32 [26] => 116 [27] => 104 [28] => 101 [29] => 32 [30] => 108 [31] => 97 [32] => 122 [33] => 121 [34] => 32 [35] => 100 [36] => 111 [37] => 103 [38] => 46 )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString("The quick fox jumped over the lazy dog.\r\nThe dog wasn't happy about that.");
echo $my->htmlNl2Br()->htmlAppendBreak();
echo $my->htmlCompatible()->htmlAppendBreak();
echo $my->htmlTagEnclose('<div style="border:solid 1px red; padding:5px; background-color:yellow;">');
?>Result:
The quick fox jumped over the lazy dog.
The dog wasn't happy about that.
The quick fox jumped over the lazy dog. The dog wasn't happy about that.The quick fox jumped over the lazy dog. The dog wasn't happy about that.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my->encodeBase64() . '<br/>';
echo $my->encodeBase64()->decodeBase64() . '<br/>';
echo $my->encodeRot13() . '<br/>';
echo $my->encodeRot13()->decodeRot13() . '<br/>';
echo $my->encodeUu()->htmlCompatible() . '<br/>';
echo $my->encodeUu()->decodeUu() . '<br/>';
echo '<br/>';
$my ->set('The quick <b>fox</b> jumped over the lazy <b>dog</b>.');
echo $my->encodeHtml() . '<br/>';
echo $my->encodeHtml()->decodeHtml() . '<br/>';
?>Result:
VGhlIHF1aWNrIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu
The quick fox jumped over the lazy dog.
ITuyVUS1nJAeVTMirPOdqJ1jMJDto3MypvO0nTHtoTS6rFOxo2ph
The quick fox jumped over the lazy dog.
G5&AE('%U:6-K(&9O>"!J=6UP960@;W9E<B!T:&4@;&%Z>2!D;V<N `
The quick fox jumped over the lazy dog.
The quick <b>fox</b> jumped over the lazy <b>dog</b>.
The quick fox jumped over the lazy dog.
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick fox jumped over the lazy dog.');
echo $my->crc32() . '<br/>';
echo $my->encodeMd5() . '<br/>';
echo $my->encodeSha1() . '<br/>';
?>Result:
2677112368
75cfc6616051afd9c31ce3b80f7496de
6bc0e2664fab912f2130f84550259646927775ac
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('The quick, quick fox jumped over the lazy dog.');
echo $my->length() . '<br/>';
echo $my->charsCount() . '<br/>';
echo $my->uniqueCharsCount() . '<br/>';
echo $my->uniqueCharsCount(true) . '<br/>';
echo $my->wordsCount() . '<br/>';
echo $my->uniqueWordsCount() . '<br/>';
echo $my->uniqueWordsCount(true) . '<br/>';
?>Result:
46
46
25
26
9
7
8
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->soundsLike('apple') ? $my->append(' sounds like "apple"') : $my->append(' does not sound like "apple"'); echo '<br/>';
echo $my->soundsLike('aple') ? $my->append(' sounds like "aple"') : $my->append(' does not sound like "aple"'); echo '<br/>';
echo $my->soundsLike('epl') ? $my->append(' sounds like "epl"') : $my->append(' does not sound like "epl"'); echo '<br/>';
echo $my->soundsLike('epl', 70) ? $my->append(' sounds like "epl"') : $my->append(' does not sound like "epl"'); echo '<br/>';
?>Result:
apple sounds like "apple"
apple sounds like "aple"
apple sounds like "epl"
apple does not sound like "epl"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->soundex() . '<br/>';
echo $my->metaphone() . '<br/>';
?>Result:
A140
APL
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->levenshtein('apple') . ' operations needed to obtain "apple"<br/>';
echo $my->levenshteinPercent('apple') . '% match "apple"<br/>';
echo '<br/>';
echo $my->levenshtein('aple') . ' operations needed to obtain "aple"<br/>';
echo $my->levenshteinPercent('aple') . '% match "aple"<br/>';
echo '<br/>';
echo $my->levenshtein('aplo') . ' operations needed to obtain "aplo"<br/>';
echo $my->levenshteinPercent('aplo') . '% match "aplo"<br/>';
echo '<br/>';
echo $my->levenshtein('onion') . ' operations needed to obtain "onion"<br/>';
echo $my->levenshteinPercent('onion') . '% match "onion"<br/>';
?>Result:
0 operations needed to obtain "apple"
100% match "apple"
1 operations needed to obtain "aple"
80% match "aple"
2 operations needed to obtain "aplo"
60% match "aplo"
5 operations needed to obtain "onion"
0% match "onion"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->soundexPercent('apple') . '% match "apple"<br/>';
echo $my->soundexPercent('aple') . '% match "aple"<br/>';
echo $my->soundexPercent('aplo') . '% match "aplo"<br/>';
echo $my->soundexPercent('epl') . '% match "epl"<br/>';
echo $my->soundexPercent('onion') . '% match "onion"<br/>';
echo $my->soundexPercent('cabbage') . '% match "cabbage"<br/>';
echo $my->soundexPercent('painting') . '% match "painting"<br/>';
?>Result:
100% match "apple"
100% match "aple"
100% match "aplo"
75% match "epl"
25% match "onion"
50% match "cabbage"
0% match "painting"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->metaphonePercent('apple') . '% match "apple"<br/>';
echo $my->metaphonePercent('aple') . '% match "aple"<br/>';
echo $my->metaphonePercent('aplo') . '% match "aplo"<br/>';
echo $my->metaphonePercent('epl') . '% match "epl"<br/>';
echo $my->metaphonePercent('onion') . '% match "onion"<br/>';
echo $my->metaphonePercent('cabbage') . '% match "cabbage"<br/>';
echo $my->metaphonePercent('painting') . '% match "painting"<br/>';
?>Result:
100% match "apple"
100% match "aple"
100% match "aplo"
66.67% match "epl"
0% match "onion"
0% match "cabbage"
0% match "painting"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->intersectionPercent('apple') . '% match "apple"<br/>';
echo $my->intersectionPercent('aple') . '% match "aple"<br/>';
echo $my->intersectionPercent('aplo') . '% match "aplo"<br/>';
echo $my->intersectionPercent('epl') . '% match "epl"<br/>';
echo $my->intersectionPercent('onion') . '% match "onion"<br/>';
echo $my->intersectionPercent('cabbage') . '% match "cabbage"<br/>';
echo $my->intersectionPercent('painting') . '% match "painting"<br/>';
?>Result:
100% match "apple"
88.89% match "aple"
66.67% match "aplo"
50% match "epl"
0% match "onion"
33.33% match "cabbage"
15.38% match "painting"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apple');
echo $my->matchPercent('apple') . '% match "apple"<br/>';
echo $my->matchPercent('aple') . '% match "aple"<br/>';
echo $my->matchPercent('aplo') . '% match "aplo"<br/>';
echo $my->matchPercent('epl') . '% match "epl"<br/>';
echo $my->matchPercent('onion') . '% match "onion"<br/>';
echo $my->matchPercent('cabbage') . '% match "cabbage"<br/>';
echo $my->matchPercent('painting', true, true, true, true) . '% match "painting"<br/>';
?>Result:
100% match "apple"
92.22% match "aple"
81.67% match "aplo"
57.92% match "epl"
6.25% match "onion"
20.83% match "cabbage"
3.85% match "painting"
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('apl');
echo $my->getClosestMatch();
echo '<pre>' . print_r($my->getMatches(), true) . '</pre>';
echo '<pre>' . print_r($my->getMatches(20), true) . '</pre>';
echo '<br/>';
$my->set('The qiuck fox jmepud oevr the lazy dog.');
echo $my->spellEmphasize() . '<br/>';
echo $my->spellAutoCorrect();
echo '<pre>' . print_r($my->spellCheck(), true) . '</pre>';
?>Result:
appliqueArray ( )Array ( [0] => Array ( [word] => applique [percent] => 49.06 ) )
the qiuck fox jmepud oevr the lazy dog.
The quick fox jumped over The lazy dog.Array ( [The] => The [qiuck] => quick [jmepud] => jumped [oevr] => over [the] => The )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$my = new wlString('applemubojumbo');
echo $my->getClosestMatch('AonawareCom') . '<br/>';
echo '<br/>';
$my->set('applewqrew');
echo $my->getClosestMatch('AonawareCom') . '<br/>';
echo '<br/>';
$my->set('The qiuck fox jmepud oevr the lazy dog.');
echo $my->spellEmphasize('AonawareCom') . '<br/>';
echo $my->spellAutoCorrect('AonawareCom') . '<br/>';
?>Result:
applemubojumbo
applique
the qiuck fox jmepud oevr the lazy dog.
The quick fox jumped over The lazy dog.