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";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->scramble() . '<br/>';
echo $s->reverse() . '<br/>';
echo $s->shuffle() . '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('狐狸回答說回狗:我很對不起我親愛的狗!', 'UTF-8');
echo $s->emphasize(array('狗:', '狐狸')) . '<br/>';
echo $s->emphasize(array('狗:', '狐狸'), true, '<em>', '<b>') . '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->shorten(10) . '<br/>';
echo $s->shorten(10, 0) . '<br/>';
echo $s->shorten(10, 0.1) . '<br/>';
echo $s->shorten(10, 0.5) . '<br/>';
echo $s->shorten(10, 0.7) . '<br/>';
echo $s->shorten(10, 1, ' ... <a href="#">[更多]</a>');
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s . '<br/>';
$s1 = $s->copy();
echo $s1->get() . '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('', 'UTF-8');
$s->load('http://a-site-url.com/the-page.html');
$s->load('path-to-a-local-file.txt');
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('123456', 'UTF-8');
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:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('htp://www.wiseloop.com', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('www.wiseloop.com', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop.', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://wiseloop.com', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
$s = new wlString('http://www.wiseloop.com', 'UTF-8');
echo $s->isUrl() ? $s->append(' is a valid url') : $s->append(' is an invalid url'); echo '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('infoemail.com', 'UTF-8');
echo $s->isEmail() ? $s->append(' is a valid email address') : $s->append(' is an invalid email address'); echo '<br/>';
$s = new wlString('info@emailcom', 'UTF-8');
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', 'UTF-8');
echo $s->isEmail() ? $s->append(' is a valid email address') : $s->append(' is an invalid email address'); echo '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('192', 'UTF-8');
echo $s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
$s = new wlString('192.168', 'UTF-8');
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.', 'UTF-8');
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', 'UTF-8');
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', 'UTF-8');
echo $s->isIp() ? $s->append(' is a valid IP address') : $s->append(' is an invalid IP address'); echo '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('123456', 'UTF-8');
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:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('13/04/2011', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('04/13/2011', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011/04/13', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011-04-13', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('2011-Apr-13', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('13-April 2011', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('13Apr11', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('April 13st, 2011', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('Apr-13-11', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
$s = new wlString('11-Apr-13', 'UTF-8');
echo $s->isDate() ? $s->append(' is a valid date') : $s->append(' is an invalid date'); echo '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
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:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString(' 123456789$% 敏捷的棕色狐狸躍過那隻懶狗。 123456789@#$ ');
echo $s->trimStart('1..9 %$') . '<br/>';
echo $s->trimEnd('1..9 @#$.') . '<br/>';
echo $s->trimBoth('1..9 @#$%.');
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->insert('紅色的 ', 17) . '<br/>';
echo $s->insert('紅色的 ', 17)->append('狗睡覺。'). '<br/>';
echo $s->remove(4, 7) . '<br/>';
echo $s->substitute('狐狸', '蝸牛'). '<br/>';
echo $s->replace(array('狐狸'), array('蝸牛')). '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('快速,棕色狐狸跳過懶惰的狗!懶惰的狗的狗仍睡著了。', 'UTF-8');
echo $s->chunkSplit()->htmlNl2Br() . '<br/>';
echo $s->chunkSplit(10)->htmlNl2Br() . '<br/>';
echo '<pre>' . print_r($s->split(10), true) . '</pre>';
echo '<pre>' . print_r($s->explode('!'), true) . '</pre>';
Result:
Array ( [0] => 快速,棕色狐狸跳過懶 [1] => 惰的狗!懶惰的狗的狗 [2] => 仍睡著了。 )
Array ( [0] => 快速,棕色狐狸跳過懶惰的狗 [1] => 懶惰的狗的狗仍睡著了。 )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->substring(0, 25)->append('.') . '<br/>';
echo $s->between('敏捷的棕色', '躍過') . '<br/>';
echo $s->between('躍過') . '<br/>';
echo $s->intersect('狐狸跳進了一個洞。') . '<br/>';
echo $s->intersectChars('狐狸跳進了一個洞。') . '<br/>';
echo $s->intersectWords('狐狸跳進了一個洞。');
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
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:
Array ( [0] => 敏 [1] => 捷 [2] => 的 [3] => 棕 [4] => 色 [5] => 狐 [6] => 狸 [7] => 躍 [8] => 過 [9] => 那 [10] => 隻 [11] => 懶 [12] => 狗 [13] => 。 )
Array ( [敏] => 1 [捷] => 1 [的] => 1 [棕] => 1 [色] => 1 [狐] => 1 [狸] => 1 [躍] => 1 [過] => 1 [那] => 1 [隻] => 1 [懶] => 1 [狗] => 1 [。] => 1 )
Array ( [敏] => 1 [捷] => 1 [的] => 1 [棕] => 1 [色] => 1 [狐] => 1 [狸] => 1 [躍] => 1 [過] => 1 [那] => 1 [隻] => 1 [懶] => 1 [狗] => 1 [。] => 1 )
Array ( [0] => 230 [1] => 230 [2] => 231 [3] => 230 [4] => 232 [5] => 231 [6] => 231 [7] => 232 [8] => 233 [9] => 233 [10] => 233 [11] => 230 [12] => 231 [13] => 227 )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('這是我的電話號碼:0040123425893。你平衡是:1025.45美元');
echo '<pre>' . print_r($s->extractNumbers(), true). '</pre>';
Result:
Array ( [0] => 0040123425893 [1] => 1025.45 )
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->firstIndex('狐狸') . '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString("敏捷的棕色狐狸躍過那隻懶狗。\r\n狗是不高興的。", 'UTF-8');
echo $s->htmlNl2Br()->htmlAppendBreak();
echo $s->htmlCompatible()->htmlAppendBreak();
echo $s->htmlTagEnclose('<div style="border:solid 1px red; padding:5px; background-color:yellow;">');
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
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('敏捷的棕色<b>狐狸</b>躍過那隻懶狗。');
echo $s->encodeHtml() . '<br/>';
echo $s->encodeHtml()->decodeHtml() . '<br/>';
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('敏捷的棕色狐狸躍過那隻懶狗。', 'UTF-8');
echo $s->crc32() . '<br/>';
echo $s->encodeMd5() . '<br/>';
echo $s->encodeSha1();
Result:
<?php
require_once dirname(__FILE__)."/../../php-advanced-string-classes/bin/wlString.php";
$s = new wlString('的快,快狐狸躍過那隻懶狗。', 'UTF-8');
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: