PHP Advanced String Classes

PHP Advanced String Classes

Extended PHP strings processing library

Features Preview

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.

01. STRING EFFECTS

Shorten

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("The quick brown fox jumped over the lazy dog.");
echo 
$s->shorten(10) . '<br/>';
echo 
$s->shorten(100) . '<br/>';
echo 
$s->shorten(100.1) . '<br/>';
echo 
$s->shorten(100.5) . '<br/>';
echo 
$s->shorten(100.7) . '<br/>';
echo 
$s->shorten(101' ... <a href="#">[Read More]</a>');

Result:

The q ... dog.
... lazy dog.
T ... lazy dog.
The q ... dog.
The qui ... og.
The quick ... [Read More]

Common Fx

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("The quick brown fox jumped over the lazy dog.");
echo 
$s->scramble() . '<br/>';
echo 
$s->reverse() . '<br/>';
echo 
$s->shuffle() . '<br/>';
echo 
$s->seoFriendly() . '<br/>';

Result:

The qucik borwn fox jemupd over the lazy dog.
.god yzal eht revo depmuj xof nworb kciuq ehT
bu op jeeTkegomd t fowcarh .x nhqzuovreilyd
the-quick-brown-fox-jumped-over-the-lazy-dog

Censor

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("The dog said: screw you stupid fox!");
echo 
$s->censor() . '<br/>';
echo 
$s->censor(false'*') . '<br/>';
echo 
$s->censorWords() . '<br/>';
echo 
$s->censorWords(array('screw''stupid'));

Result:

Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx!
***********************************
Txe dog said: sxxxw you stupid fox!
The dog said: sxxxw you sxxxxd fox!

Emphasize

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("The fox replied back to the dog: I'm very sorry my dear dog!");
echo 
$s->emphasize(array('the dog''fox')) . '<br/>';
echo 
$s->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!

02. BASIC OPERATIONS

Loading Files

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString();
//$s->load('http://a-site-url.com/the-page.html');
//$s->load('path-to-a-local-file.txt');

Result:

Constructor And Echo

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s '<br/>';
$my1 $s->copy();
echo 
$my1->get() . '<br/>';

Result:

The quick fox jumped over the lazy dog.
The quick fox jumped over the lazy dog.

03. VALIDATION

Email Address Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('infoemail.com');
echo 
$s->isEmail() ? $s->append(' is a valid email address') : $s->append(' is an invalid email address'); echo '<br/>';
$s = new wlString('info@emailcom');
echo 
$s->isEmail() ? $s->append(' is a valid email address') : $s->append(' is an invalid email address'); echo '<br/>';
$s = new wlString('info@email.com');
echo 
$s->isEmail() ? $s->append(' is a valid email address') : $s->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

Alpha Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('123456');
echo 
$s->isAlpha() ? $s->append(' is alpha') : $s->append(' is not alpha'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc ');
echo 
$s->isAlpha() ? $s->append(' is alpha') : $s->append(' is not alpha'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
$s->inRange('Ab''cde') ? $s->append(' is between "Ab" and "cde"') : $s->append(' is not between "Ab" and "cde"'); echo '<br/>';
echo 
$s->inRange('Bet''Rex') ? $s->append(' is between "Bet" and "Rex"') : $s->append(' is not between "Bet" and "Rex"'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc 123456');
echo 
$s->isAlpha() ? $s->append(' is alpha') : $s->append(' is not alpha'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc 123456 #');
echo 
$s->isAlpha() ? $s->append(' is alpha') : $s->append(' is not alpha'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->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

Casing Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog');
echo 
'Capital: '; echo $s->isCapitalCase() ? 'yes' 'no'; echo '<br/>';
echo 
'Lower: '; echo $s->isLowerCase() ? 'yes' 'no'; echo '<br/>';
echo 
'Upper: '; echo $s->isUpperCase() ? 'yes' 'no'; echo '<br/>';
echo 
'Sentence: '; echo $s->isSentenceCase() ? 'yes' 'no'; echo '<br/>';
echo 
'Empty: '; echo $s->isEmpty() ? 'yes' 'no'; echo '<br/>';
echo 
'White: '; echo $s->isWhite() ? 'yes' 'no'; echo '<br/>';
echo 
'<br/>';
$s = new wlString(' ');
echo 
'Empty: '; echo $s->isEmpty() ? 'yes' 'no'; echo '<br/>';
echo 
'White: '; echo $s->isWhite() ? 'yes' 'no'; echo '<br/>';

Result:

Capital: yes
Lower: no
Upper: no
Sentence: no
Empty: no
White: no

Empty: no
White: yes

Numeric Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('123456');
echo 
$s->isNumeric() ? $s->append(' is numeric') : $s->append(' is not numeric'); echo '<br/>';
echo 
$s->isFloat() ? $s->append(' is float') : $s->append(' is not float'); echo '<br/>';
echo 
$s->isInteger() ? $s->append(' is integer') : $s->append(' is not integer'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
$s->inRange('10''3445') ? $s->append(' is between 10 and 3445') : $s->append(' is not between 10 and 3445'); echo '<br/>';
echo 
$s->inRange('123455''12345678') ? $s->append(' is between 123455 and 12345678') : $s->append(' is not between 123455 and 12345678'); echo '<br/>';
echo 
'<br/>';
$s->set('123456.35');
echo 
$s->isNumeric() ? $s->append(' is numeric') : $s->append(' is not numeric'); echo '<br/>';
echo 
$s->isFloat() ? $s->append(' is float') : $s->append(' is not float'); echo '<br/>';
echo 
$s->isInteger() ? $s->append(' is integer') : $s->append(' is not integer'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
$s->inRange('10''3445') ? $s->append(' is between 10 and 3445') : $s->append(' is not between 10 and 3445'); echo '<br/>';
echo 
$s->inRange('123455''12345678') ? $s->append(' is between 123455 and 12345678') : $s->append(' is not between 123455 and 12345678'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc ');
echo 
$s->isNumeric() ? $s->append(' is numeric') : $s->append(' is not numeric'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc 123456');
echo 
$s->isNumeric() ? $s->append(' is numeric') : $s->append(' is not numeric'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->append(' is not alphanumeric'); echo '<br/>';
echo 
'<br/>';
$s->set('Abc 123456 #');
echo 
$s->isNumeric() ? $s->append(' is numeric') : $s->append(' is not numeric'); echo '<br/>';
echo 
$s->isAlphaNumeric() ? $s->append(' is alphanumeric') : $s->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

Date Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('13/04/2011');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('04/13/2011');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011/04/13');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011-04-13');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011-Apr-13');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('13-April 2011');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('13Apr11');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('April 13st, 2011');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('Apr-13-11');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('11-Apr-13');
echo 
$s->isDate() ? $s->append(' is a valid date') : $s->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

Hex Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('123456');
echo 
$s->isHexColor() ? $s->append(' is hex color') : $s->append(' is not hex color'); echo '<br/>';
$s->set('#123456');
echo 
$s->isHexColor() ? $s->append(' is hex color') : $s->append(' is not hex color'); echo '<br/>';
$s->set('#F3D4AE');
echo 
$s->isHexColor() ? $s->append(' is hex color') : $s->append(' is not hex color'); echo '<br/>';
$s->set('#F3K4AE');
echo 
$s->isHexColor() ? $s->append(' is hex color') : $s->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

Url Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('htp://www.wiseloop.com');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('www.wiseloop.com');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop.');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop.com');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://www.wiseloop.com');
echo 
$s->isUrl() ? $s->append(' is a valid url') : $s->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

Ip Validation

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('192');
echo 
$s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
$s = new wlString('192.168');
echo 
$s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
$s = new wlString('192.168.100.');
echo 
$s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
$s = new wlString('192.168.1002.101');
echo 
$s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
$s = new wlString('192.168.100.101');
echo 
$s->isIp() ? $s->append(' is a valid IP address') : $s->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

04. ALTERING

Padding

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('the quick, brown fox jumped over the lazy dog');
echo 
$s->padLeft(50'#')->htmlAppendBreak();
echo 
$s->padRight(50'#')->htmlAppendBreak();
echo 
$s->padBoth(50'#')->htmlAppendBreak();
echo 
$s->padLeft(50'-')->padRight(60'=')->htmlAppendBreak();
echo 
'<br/>';
echo 
$s->enclose('123 '' 456')->htmlAppendBreak();
echo 
$s->enclose('---| ')->htmlAppendBreak();
echo 
$s->enclose('(')->htmlAppendBreak();
echo 
$s->enclose('[')->htmlAppendBreak();
echo 
$s->enclose('{')->htmlAppendBreak();
echo 
$s->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"

Word Wrapping

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick, brown fox jumped over the lazy dog! The lazy doggy dog remained asleep.');
echo 
'<pre>'print_r($s->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. 
)

Trimming

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString(' 123456789$% The quick fox jumped over the lazy dog. 123456789@#$ ');
echo 
$s->trimStart('1..9 %$') . '<br/>';
echo 
$s->trimEnd('1..9 @#$.') . '<br/>';
echo 
$s->trimBoth('1..9 @#$%.') . '<br/>';
echo 
$s->removeNonAlphaNumeric() . '<br/>';
echo 
$s->removeNonAlpha() . '<br/>';
echo 
$s->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

Splitting

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick, brown fox jumped over the lazy dog! The lazy doggy dog remained asleep.');
echo 
$s->chunkSplit()->htmlNl2Br() . '<br/>';
echo 
$s->chunkSplit(25)->htmlNl2Br() . '<br/>';
echo 
'<pre>' print_r($s->split(25), true) . '</pre>';
echo 
'<pre>' print_r($s->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.
)

Casing

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('the quick FOX jumped over the lazy DOG.');
echo 
$s->toLowerCase() . '<br/>';
echo 
$s->toUpperCase() . '<br/>';
echo 
$s->toCapitalCase() . '<br/>';
echo 
$s->toSentenceCase() . '<br/>';
echo 
$s->toRandomCase() . '<br/>';
echo 
$s->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.

Basics

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick, quick fox jumped over the lazy dog.');
echo 
$s->insert('red '17) . '<br/>';
echo 
$s->insert('red '17)->append(' The dog was sleeping.'). '<br/>';
echo 
$s->remove(47) . '<br/>';
echo 
$s->substitute('quick''red'). '<br/>';
echo 
$s->substitute('quick''red'1). '<br/>';
echo 
$s->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.

05. GENERATING

String Generators

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('I copied this 102500 file for 5437894 times.');
echo 
$s->append(' ')->repeat(3) . '<br/>';
echo 
$s->generatePassword() . '<br/>';
echo 
$s->generateGUID() . '<br/>';
echo 
'<pre>' print_r($s->spellExtractedNumber(), true) . '</pre>';
echo 
'<pre>' print_r($s->byteSizeExtractedNumber(), true) . '</pre>';
echo 
$s->spellExtractedNumber(0) . '<br/>';
echo 
$s->spellExtractedNumber(1) . '<br/>';
echo 
$s->byteSizeExtractedNumber(0) . '<br/>';
echo 
$s->spellNumbers() . '<br/>';
echo 
$s->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.
IfxoLjs1
0a977ecb42b7be99743492439c123bbe
Array
(
    [0] => wlString Object
        (
            [_s:wlString:private] => one hundred two thousand five hundred  
            [_encoding:wlString:private] => 
        )

    [1] => wlString Object
        (
            [_s:wlString:private] => five million four hundred thirty seven thousand eight hundred ninety four 
            [_encoding:wlString:private] => 
        )

)
Array
(
    [0] => wlString Object
        (
            [_s:wlString:private] => 100.10 KB
            [_encoding:wlString:private] => 
        )

    [1] => wlString Object
        (
            [_s:wlString:private] => 5.19 MB
            [_encoding:wlString: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.

06. EXTRACTING

Searching

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s->firstIndex('not-found') . '<br/>';
echo 
$s->firstIndex('the') . '<br/>';
echo 
$s->firstIndex('the'0true) . '<br/>';
echo 
$s->lastIndex('the') . '<br/>';

Result:


0
26
26

Words Operations

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = 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($s->words(), true). '</pre>';
echo 
'<pre>' print_r($s->uniqueWords(), true). '</pre>';
echo 
'<pre>' print_r($s->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
)

Numbers

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('This is my phone number: +0040123425893. You balance is: $1025.45');
echo 
'<pre>' print_r($s->extractNumbers(), true). '</pre>';

Result:

Array
(
    [0] => 0040123425893
    [1] => 1025.45
)

String Operations

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s->substring(025)->append('.') . '<br/>';
echo 
$s->between('quick''the') . '<br/>';
echo 
$s->between('over') . '<br/>';
echo 
$s->between('the''dog''the') . '<br/>';
echo 
$s->intersect('The fox jumped into a hole.') . '<br/>';
echo 
$s->intersect(new wlString('The fox jumped into a hole.')) . '<br/>';
echo 
$s->intersectChars('The fox jumped into a hole.') . '<br/>';
echo 
$s->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

Character Operations

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s->char(2) . '<br/>';
echo 
'<pre>' print_r($s->chars(), true). '</pre>';
echo 
'<pre>' print_r($s->uniqueChars(), true). '</pre>';
echo 
'<pre>' print_r($s->uniqueChars(true), true). '</pre>';
echo 
'<pre>' print_r($s->ord(), true). '</pre>';

Result:

e
Array
(
    [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
)

07. HTML

Html Functions

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("The quick fox jumped over the lazy dog.\r\nThe dog wasn't happy about that.");
echo 
$s->htmlNl2Br()->htmlAppendBreak();
echo 
$s->htmlCompatible()->htmlAppendBreak();
echo 
$s->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.

08. ENCODING

Encrypting

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s->crc32() . '<br/>';
echo 
$s->encodeMd5() . '<br/>';
echo 
$s->encodeSha1() . '<br/>';

Result:

2677112368
75cfc6616051afd9c31ce3b80f7496de
6bc0e2664fab912f2130f84550259646927775ac

Encoding Decoding

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick fox jumped over the lazy dog.');
echo 
$s->encodeBase64() . '<br/>';
echo 
$s->encodeBase64()->decodeBase64() . '<br/>';
echo 
$s->encodeRot13() . '<br/>';
echo 
$s->encodeRot13()->decodeRot13() . '<br/>';
echo 
$s->encodeUu()->htmlCompatible() . '<br/>';
echo 
$s->encodeUu()->decodeUu() . '<br/>';
echo 
'<br/>';
$s ->set('The quick <b>fox</b> jumped over the lazy <b>dog</b>.');
echo 
$s->encodeHtml() . '<br/>';
echo 
$s->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.

09. STATISTICS

Counting

<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('The quick, quick fox jumped over the lazy dog.');
echo 
$s->length() . '<br/>';
echo 
$s->charsCount() . '<br/>';
echo 
$s->uniqueCharsCount() . '<br/>';
echo 
$s->uniqueCharsCount(true) . '<br/>';
echo 
$s->wordsCount() . '<br/>';
echo 
$s->uniqueWordsCount() . '<br/>';
echo 
$s->uniqueWordsCount(true) . '<br/>';

Result:

46
46
25
26
9
7
8