Laravel 8 contains {#collection-method}

2021-07-19 10:31 更新

contains 方法判斷指定字符串中是否包含另一指定字符串(區(qū)分大小寫):

use Illuminate\Support\Str;

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

// true 

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

use Illuminate\Support\Str;

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

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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)