Laravel 8 endsWith {#collection-method}

2021-07-19 10:32 更新

endsWith 方法用于判斷指定字符串是否以另一指定字符串結(jié)尾:

use Illuminate\Support\Str;

$result = Str::of('This is my name')->endsWith('name');

// true 

您亦可以傳遞數(shù)組的值的形式來判斷指定字符串是否包含指定數(shù)組中的任一值:

use Illuminate\Support\Str;

$result = Str::of('This is my name')->endsWith(['name', 'foo']);

// true

$result = Str::of('This is my name')->endsWith(['this', 'foo']);

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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號