字符串

2018-02-24 15:52 更新

camel_case

把給定的字串轉(zhuǎn)換成 駝峰式命名。

$camel = camel_case('foo_bar');

// fooBar

class_basename

取得給定類的類名稱,不含任何命名空間的名稱。

$class = class_basename('Foo\Bar\Baz');

// Baz

e

對(duì)給定字串執(zhí)行 htmlentities,并支持 UTF-8。

$entities = e('<html>foo</html>');

ends_with

判斷句子結(jié)尾是否有給定的字串。

$value = ends_with('This is my name', 'name');

snake_case

把給定的字串轉(zhuǎn)換成 蛇形命名。

$snake = snake_case('fooBar');

// foo_bar

str_limit

限制字串的字符數(shù)量。

str_limit($value, $limit = 100, $end = '...')

例子:

$value = str_limit('The PHP framework for web artisans.', 7);

// The PHP...

starts_with

判斷句子是否開頭有給定的字串。

$value = starts_with('This is my name', 'This');

str_contains

判斷句子是否有給定的字串。

$value = str_contains('This is my name', 'my');

str_finish

加一個(gè)給定字串到句子結(jié)尾。多余一個(gè)的給定字串則移除。

$string = str_finish('this/string', '/');

// this/string/

str_is

判斷字串是否符合給定的模式。星號(hào)可以用來當(dāng)作通配符。

$value = str_is('foo*', 'foobar');

str_plural

把字串轉(zhuǎn)換成它的多數(shù)形態(tài) (只有英文)。

$plural = str_plural('car');

str_random

產(chǎn)生給定長(zhǎng)度的隨機(jī)字串。

$string = str_random(40);

str_singular

把字串轉(zhuǎn)換成它的單數(shù)形態(tài) (只有英文)。

$singular = str_singular('cars');

str_slug

從給定字串產(chǎn)生一個(gè)對(duì)網(wǎng)址友善的「slug」。

str_slug($title, $separator);

例子:

$title = str_slug("Laravel 5 Framework", "-");

// laravel-5-framework

studly_case

把給定字串轉(zhuǎn)換成 首字大寫命名。

$value = studly_case('foo_bar');

// FooBar

trans

翻譯給定的語(yǔ)句。等同 Lang::get。

$value = trans('validation.required'):

trans_choice

隨著詞形變化翻譯給定的語(yǔ)句。等同 Lang::choice。

$value = trans_choice('foo.bar', $count);

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)