Str::endWith

Posted on November 25, 2016

The Str::endWith function determines if the given string ends with the given value.

As i mentioned before the second parameter can be a string or an array of strings. In case it is a string the method returns true or false accordingly by checking in a case-sensitive manner. In case we pass an array of strings then the method returns true as long as one of the strings is the correct one.

Example usage

$result = Str::endWith('This is my name', 'name');
// true

$result = Str::endsWith('Lolita Framework is really awesome', 'Awesome');
// false

$result = Str::endsWith('Lolita Framework is really awesome', ['Awesome', 'awesome']);
// true

Parameters

string $haystack

string|array $needles

Return Value

bool

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *