#ARQUIVO 1- strings.php
lowercase($p); }
function uppercase($p) { return preg_replace(\"/([à-ý]|[a-z])/e\",\"chr(ord(\'\\\\1\')-32)\", $p); }
function strtoupper($p) { return $this->uppercase($p); }
function ucfirst($p) { return preg_replace(\"/^([à-ý]|[a-z]){1,1}/e\",\"chr(ord(\'\\\\1\')-32)\", $p); }
function lcfirst($p) { return preg_replace(\"/^([À-Ý]|[A-Z]){1,1}/e\",\"chr(ord(\'\\\\1\')+32)\", $p); }
function ucwords($p) {
$c = explode(\" \", $p);
if ($c) {
$d = array();
while (list($a,$b) = each($c)) {
array_push($d,preg_replace(\"/^([à-ý]|[a-z]){1,1}/e\",\"chr(ord(\'\\\\1\')-32)\", $b));
}
return join(\" \", $d);
}
}
function lcwords($p) {
$c = explode(\" \", $p);
if ($c) {
$d = array();
while (list($a,$b) = each($c)) {
array_push($d,preg_replace(\"/^([À-Ý]|[A-Z]){1,1}/e\",\"chr(ord(\'\\\\1\')+32)\", $b));
}
return join(\" \", $d);
}
}
function normal($p) {
$ts = array(\"/[À-Å]/\",\"/Æ/\",\"/Ç/\",\"/[È-Ë]/\",\"/[Ì-Ï]/\",\"/Ð/\",\"/Ñ/\",\"/[Ò-ÖØ]/\",\"/×/\",\"/[Ù-Ü]/\",\"/[Ý-ß]/\",\"/[à-å]/\",\"/æ/\",\"/ç/\",\"/[è-ë]/\",\"/[ì-ï]/\",\"/ð/\",\"/ñ/\",\"/[ò-öø]/\",\"/÷/\",\"/[ù-ü]/\",\"/[ý-ÿ]/\");
$tn = array(\"A\",\"AE\",\"C\",\"E\",\"I\",\"D\",\"N\",\"O\",\"X\",\"U\",\"Y\",\"a\",\"ae\",\"c\",\"e\",\"i\",\"d\",\"n\",\"o\",\"x\",\"u\",\"y\");
return preg_replace($ts,$tn, $p);
}
function remove($p,$c) { return preg_replace(\"/$c/\",\"\", $p); }
function chomp($p) { return preg_replace(\"/[\\n\\r]/\",\"\", $p); }
function php_quote($text,$a=1,$b=1,$c=0,$d=0) {
if ($a) {$text = preg_replace(\"/\\<\\?(php)/i\",\"
#ARQUIVO 2 - Samples:
Samples of the strings class
ucwords(\'éi this ìs a rulex teséeeeeee é!
\');
print $strings->lcwords(\'ÉI THIS ÌS A RULEX TESÉEEEEEE É!
\');
print $strings->normal(\'ÉI THIS ÌS A RULEX TESÉEEEEEE É!
\');
print $strings->normal(\"faço áeéíàÒ
\");
?>
#ARQUIVO 3 - Manual
MANUAL OF class strings
>> Please, if you see an english error in this manual
send a email to berto@que.com.br. I\'m sorry but
I have little experience to write in english.
>> If you want help me to write a PHP class that
format strings like unix fmt and justify it, send-me
a email!
>> Some of my portuguese sites:
> http://www.que.com.br/php - Cronicas do PHP
artigos escritos por mim sobre php que sao enviados
periodicamente por email alem do seu arquivo de dicas.
> http://www.que.com.br/perl - Cronicas do PERL
versao para PERL do Cronicas do PHP
>> Thanks to download my class!
CLASS: strings
This class is a expansion to the original PHP string funcions.
All functions was make to use special characters (192-223 and
224-255 in ascii table).
ALIASES:
$class->strtoupper = $class->uppercase
$class->strtolower = $class->lowercase
FUNCTIONS:
All functions above knows how convert a special char to their
upper/lower case, like covert a to Á or È to è.
* uppercase - make a string uppercase
string $class->uppercase(string string);
use like strtoupper PHP function
* lowercase - make a string lowercase
string $class->lowercase(string string);
use like strtolower PHP function
* ucfirst - make a string\'s first character uppercase
string $class->ucfirst(string string);
use like ucfirst PHP function
* lcfirst - make a string\'s first character lowercase
string $class->lcfirst(string string);
use like ucfirst PHP function
* lcfirst - make a string\'s first character lowercase
string $class->lcfirst(string string);
use like lcfirst PHP function
* ucwords - uppercase the first character of each word in a string
string $class->ucwords(string string);
use like ucwords PHP function
* lcwords - lowercase the first character of each word in a string
string $class->lcwords(string string);
use like lcwords PHP function
* normal - converts each special character (áéíÁÈÒÖ) to their
normal character (aeiAEOO)
string $class->normal(string string);
Example:
normal(\"faço áeéíàÒ\");
# will output: faco aeeiaO
?>
* remove - remove a string from an other
string $class->remove(string string,string to remove);
Example:
remove($remove,\"\\r\");
$remove = $strings->remove($remove,\"\\n\");
# will output: removing the carriege return and the line break
?>
* chomp - remove the \\r and the \\n from a string
string $class->chomp(string string);
Example:
remove($remove);
# will output: removing the carriege return and the line break
?>
* php_quote - remove the PHP open strings
string $class->php_quote(string string,bool and/or <% from a
string. You can choice what remove. The default is remove tags
If is TRUE will remove tags
If <% is TRUE will remove <% tags
Note that this function dont remove the tags, it put a comment there.
Example to remove ONLY SCRIPT and <% tags:
php_quote(\'
is cool to
BUT:
AND
<% isn\'t cool too!
\',0,1,0,1);
?>
* file_ext - return the extension of a filename
string $class->file_ext(string string);
Return only the extension of a filename.
Example:
file_ext(\"lilo.conf\");
# will output: conf
?>
* file_noext - return the filename without its extension
string $class->file_noext(string string);
Return only the name of a filename widthout \".extension\"
Example:
file_noext(\"lilo.conf\");
# will output: lilo
?>
* stripdouble - return a string with no double //
string $class->stripdouble(string string);
This function is util to work with filepaths. It remove
the double // but no replace // to / in http:// and ftp://
Example:
stripdouble(\"http://localhost?file=/home/me//dir///algo\");
# will output: http://localhost?file=/home/me/dir/algo
?>
last modify 01/12/2000 17:17 by Roberto Berto (berto@que.com.br)