pclib
3.0.0
Lightweight PHP framework
|
String utilities for utf-8 strings. More...
Static Public Member Functions | |
static | format ($str, array $params, $keepEmpty=false) |
Replace {param} placeholders in string with values from array $param. More... | |
static | extractPath ($path, $format) |
Extract part of the filesystem path. More... | |
static | htmlTag ($name, array $attr=[], $content=null) |
Create html tag. More... | |
static | random ($size=16, $characters=self::ALPHANUM) |
Return random string with $size characters. More... | |
static | match ($str, $pattern) |
Match $pattern on $str and return result or empty string. More... | |
static | matchAll ($str, $pattern) |
Match $pattern on $str and return all results as array. More... | |
static | replace ($str, $search, $replace) |
Replace all occurences of $search in $str with $replace. More... | |
static | substr ($str, $start, $length=null) |
static | strpos ($str, $search, $offset=0) |
static | length ($str) |
static | upper ($str) |
static | lower ($str) |
static | lpad ($str, $length, $pad=' ') |
static | rpad ($str, $length, $pad=' ') |
static | startsWith ($str, $search) |
Return true if $str starts with $search. | |
static | endsWith ($str, $search) |
Return true if $str ends with $search. | |
static | filter ($str, $preserve) |
Preserve only specified characters in $str. More... | |
static | contains ($str, $search, $ignoreCase=false) |
Return true if $str contains $search. More... | |
static | webalize ($str) |
Transform string $str into url-ready form 'some-string-1234'. More... | |
static | id ($str, $preserve='\w', $separator='_') |
Remove diacriticts and non-alphanum characters from $str and replace spaces with '_'. More... | |
static | ascii ($str) |
Replace characters with diacritics to plain ascii characters. | |
static | htmlspecialchars ($str) |
String utilities for utf-8 strings.
PHP mbstring extension is required. Example of usage: print Str::upper("Hello world");
|
static |
Return true if $str contains $search.
string | $str | |
string | $search | |
bool | $ignoreCase |
|
static |
Extract part of the filesystem path.
Example: Str::extractPath($path, "%f.%e"); //extract "filename.extension"
string | $path | Filesystem path |
string | $format | Use following placeholders: d for directory, f filename, e extension. |
|
static |
Preserve only specified characters in $str.
string | $str | Source string |
string | $preserve | Which characters should be preserved (regex) e.g. "\w" |
|
static |
Replace {param} placeholders in string with values from array $param.
Example: print Str::format("Hello {name}", ['name' => 'World']); If $params is two-dimensional array of n-rows, $str is written for each row.
string | $str | string with {param} placeholders |
array | $params | array of PARAM=>VALUE or array of rows |
bool | $keepEmpty | Keep (don't delete) tags undefined in $param |
|
static |
|
static |
Create html tag.
Example: Str::htmlTag('a', ['href' => 'www.example.com'], 'Example');
string | $name | Name of the tag |
string | $attr | Tag attributes |
|
static |
Remove diacriticts and non-alphanum characters from $str and replace spaces with '_'.
Result can be used as identificator: filename, database tablename etc.
string | $str | Source string |
string | $preserve | Which characters should be preserved (regex) |
$separator | Separator of words, '_' by default |
|
static |
|
static |
|
static |
|
static |
Match $pattern on $str and return result or empty string.
string | $str | |
string | $pattern | Regexp pattern |
|
static |
Match $pattern on $str and return all results as array.
string | $str | |
string | $pattern | Regexp pattern |
|
static |
Return random string with $size characters.
int | $size | Number of characters |
string | $characters | Source characters (You can use Str::ALPHASPEC or Str::APLHANUM constants) |
|
static |
Replace all occurences of $search in $str with $replace.
string | $search | Regexp pattern |
string | $str | |
string | $replace |
|
static |
|
static |
|
static |
|
static |
|
static |
Transform string $str into url-ready form 'some-string-1234'.