abstract class StringHelper

Class StringHelper

Methods

static boolean
regexVerify(string $value, string $rule)

使用正则验证数据

static bool|int
strlen($str, string $encoding = 'UTF-8')

No description

static int|string
length([type] $str)

计算字符长度

static int
absLen(string $str)

No description

static string
utf8SubStr(string $str, int $start = 0, int $end = null)

No description

static string
zhSubStr(string $str, int $start = 0, int $length, string $charset = 'utf-8', bool $suffix = true)

No description

static string
random($length, array $param = [])

********************** 生成一定长度的随机字符串函数 **********************

static bool|string
genSalt(int $length = 32)

No description

static bool|string
genUid(int $length = 7)

No description

static string
nl2br(string $str)

Convert \n and \r\n and \r to

static bool|string
strtolower($str)

No description

static bool|string
strtoupper($str)

No description

static bool|string
substr($str, $start, bool|false $length = false, string $encoding = 'utf-8')

No description

static bool|int
strpos($str, $find, int $offset = 0, string $encoding = 'UTF-8')

No description

static bool|int
strrpos($str, $find, int $offset = 0, string $encoding = 'utf-8')

No description

static string
ucfirst($str)

No description

static string
ucwords($str)

No description

static array
toArray(string $str, string $sep = ',')

No description

static array
str2array(string $str, string $sep = ',')

var_dump(str2array('34,56,678, 678, 89, '));

static array
split2Array(string $path, string $separator = '.')

No description

static 
truncate($str, $max_length, $suffix = '...')

No description

static string
truncate_two(string $str, int $start, null|int $length = null)

字符截断输出

static bool|string
truncateString(string $text, int $length = 120, array $options = array())

Copied from CakePHP String utility file

static 
toCamel($str, $upperFirstChar = false)

No description

static mixed
toCamelCase($str, bool $upperFirstChar = false)

Translates a string with underscores into camel case (e.g. first_name -> firstName)

static 
toSnake($str, $sep = '_')

No description

static string
toSnakeCase(string $str, string $sep = '_')

Transform a CamelCase string to underscore_case string

static mixed|string
nameChange([type] $str, bool $toCamelCase = true)

驼峰式 <=> 下划线式

static string
format($str, array $replaceParams = [], array $pregParams = [])

[format description]

static string
wordFormat(string $keyword)

格式化,用空格分隔各个词组

static mixed
deleteStripSpace($fileName, int $type = 0)

缩进格式化内容,去空白/注释

Details

at line 19
static boolean regexVerify(string $value, string $rule)

使用正则验证数据

Parameters

string $value 要验证的数据
string $rule 验证规则 require email url currency number integer english

Return Value

boolean

at line 49
static bool|int strlen($str, string $encoding = 'UTF-8')

Parameters

$str
string $encoding

Return Value

bool|int

at line 61
static int|string length([type] $str)

计算字符长度

Parameters

[type] $str

Return Value

int|string [type]

at line 87
static int absLen(string $str)

Parameters

string $str 要计算长度的字符串

Return Value

int

at line 114
static string utf8SubStr(string $str, int $start = 0, int $end = null)

Parameters

string $str 要进行截取的字符串
int $start 要进行截取的开始位置,负数为反向截取
int $end 要进行截取的长度

Return Value

string

at line 156
static string zhSubStr(string $str, int $start = 0, int $length, string $charset = 'utf-8', bool $suffix = true)

Parameters

string $str 要截取的字串
int $start 截取起始位置
int $length 截取长度
string $charset utf-8|gb2312|gbk|big5 编码
bool $suffix 是否加尾缀

Return Value

string

at line 193
static string random($length, array $param = [])

********************** 生成一定长度的随机字符串函数 **********************

Parameters

$length
  • 随机字符串长度
array $param -

Return Value

string

at line 216
static bool|string genSalt(int $length = 32)

Parameters

int $length

Return Value

bool|string

at line 225
static bool|string genUid(int $length = 7)

Parameters

int $length

Return Value

bool|string

at line 256
static string nl2br(string $str)

Convert \n and \r\n and \r to

Parameters

string $str String to transform

Return Value

string New string

at line 265
static bool|string strtolower($str)

Parameters

$str

Return Value

bool|string

at line 278
static bool|string strtoupper($str)

Parameters

$str

Return Value

bool|string

at line 294
static bool|string substr($str, $start, bool|false $length = false, string $encoding = 'utf-8')

Parameters

$str
$start
bool|false $length
string $encoding

Return Value

bool|string

at line 310
static bool|int strpos($str, $find, int $offset = 0, string $encoding = 'UTF-8')

Parameters

$str
$find
int $offset
string $encoding

Return Value

bool|int

at line 323
static bool|int strrpos($str, $find, int $offset = 0, string $encoding = 'utf-8')

Parameters

$str
$find
int $offset
string $encoding

Return Value

bool|int

at line 333
static string ucfirst($str)

Parameters

$str

Return Value

string

at line 342
static string ucwords($str)

Parameters

$str

Return Value

string

at line 353
static array toArray(string $str, string $sep = ',')

Parameters

string $str
string $sep

Return Value

array

at line 376
static array str2array(string $str, string $sep = ',')

var_dump(str2array('34,56,678, 678, 89, '));

Parameters

string $str
string $sep

Return Value

array

at line 392
static array split2Array(string $path, string $separator = '.')

Parameters

string $path
string $separator

Return Value

array

at line 406
static truncate($str, $max_length, $suffix = '...')

Parameters

$str
$max_length
$suffix

at line 424
static string truncate_two(string $str, int $start, null|int $length = null)

字符截断输出

Parameters

string $str
int $start
null|int $length

Return Value

string

at line 451
static bool|string truncateString(string $text, int $length = 120, array $options = array())

Copied from CakePHP String utility file

Parameters

string $text
int $length
array $options

Return Value

bool|string

at line 578
static toCamel($str, $upperFirstChar = false)

Parameters

$str
$upperFirstChar

at line 590
static mixed toCamelCase($str, bool $upperFirstChar = false)

Translates a string with underscores into camel case (e.g. first_name -> firstName)

Parameters

$str
bool $upperFirstChar

Return Value

mixed

at line 603
static toSnake($str, $sep = '_')

Parameters

$str
$sep

at line 614
static string toSnakeCase(string $str, string $sep = '_')

Transform a CamelCase string to underscore_case string

Parameters

string $str
string $sep

Return Value

string

at line 629
static mixed|string nameChange([type] $str, bool $toCamelCase = true)

驼峰式 <=> 下划线式

Parameters

[type] $str [description]
bool $toCamelCase true : 驼峰式 => 下划线式 false : 驼峰式 <= 下划线式

Return Value

mixed|string

at line 678
static string format($str, array $replaceParams = [], array $pregParams = [])

[format description]

Parameters

$str
array $replaceParams 用于 str_replace('search','replace',$str )
array $pregParams 用于 preg_replace('pattern','replace',$str)

Return Value

string [type] [description]

at line 702
static string wordFormat(string $keyword)

格式化,用空格分隔各个词组

Parameters

string $keyword 字符串

Return Value

string 格式化后的字符串

at line 721
static mixed deleteStripSpace($fileName, int $type = 0)

缩进格式化内容,去空白/注释

Parameters

$fileName
int $type

Return Value

mixed