Method | Description | |
---|---|---|
ascii ( string $value ) : string | Convert a string to 7-bit ASCII. | |
camel ( string $value ) : string | Convert a value to camel case. | |
camelCase ( string $value ) : string | Convert a value to camel case. | |
classify ( string $value ) : string | Convert a string to an underscored, camel-cased class name. | |
contains ( string $haystack, string | array $needle ) : boolean | Determine if a given string contains a given sub-string. | |
endsWith ( string $haystack, string $needle ) : boolean | Determine if a given string ends with a given needle. | |
extension ( $fileName ) : string | Get a files extension from its path. | |
finish ( string $value, string $cap ) : string | Cap a string with a single instance of a given value. | |
is ( string $pattern, string $value ) : boolean | Determine if a given string matches a given pattern. | |
length ( $string ) : integer | Get the length of a string. | |
limit ( string $value, integer $limit = 100, string $end = '...' ) : string | Limit the number of characters in a string. | |
limitExact ( string $value, integer $limit = 100, string $end = '...' ) : string | Limit the number of chracters in a string including custom ending | |
lower ( $string ) : string | Convert a string to lowercase. | |
plural ( string $value, integer $count = 2 ) : string | Get the plural form of the given word. | |
quickRandom ( integer $length = 16 ) : string | Generate a "random" alpha-numeric string. | |
random ( integer $length, string $type = 'alnum' ) : string | Generate a random alpha or alpha-numeric string. | |
segments ( string $value ) : array | Return the "URI" style segments in a given string. | |
singular ( string $value ) : string | Get the singular form of the given word. | |
slug ( string $title, string $separator = '-', $keepExtension = false ) : string | Generate a URL friendly "slug" from a given string. | |
snake ( string $value, string $delimiter = '_' ) : string | Convert a string to snake case. | |
startsWith ( string $haystack, string $needle ) : boolean | Determine if a string starts with a given needle. | |
title ( $string ) : string | Convert a string to title case (ucwords equivalent). | |
upper ( $string ) : string | Convert a string to uppercase. | |
upperWords ( string $string ) : string | Convert first letter of each word to uppercase. | |
words ( string $value, integer $words = 100, string $end = '...' ) : string | Limit the number of words in a string. | |
wordwrap ( string $string, $length ) : string | Adds a space to a string after a given amount of contiguous, non-whitespace characters. |
Method | Description | |
---|---|---|
pool ( string $type ) : string | Get the character pool for a given type of random string. |
Returns "Task_Name"
$class = Str::classify('task_name');
Returns "Taylor_Otwell"
$class = Str::classify('taylor otwell')
Get the length of a string
$length = Str::length('Taylor Otwell');
Get the length of a multi-byte string
$length = Str::length('Τάχιστη')
Returns "Tay..."
echo Str::limit('Taylor Otwell', 3);
Limit the number of characters and append a custom ending
echo Str::limit('Taylor Otwell', 3, '---');
Returns "Taylor..."
echo Str::limitExact('Taylor Otwell', 9);
Limit the number of characters and append a custom ending
echo Str::limitExact('Taylor Otwell', 9, '---');
Convert a string to lowercase
$lower = Str::lower('Taylor Otwell');
Convert a multi-byte string to lowercase
$lower = Str::lower('Τάχιστη');
Returns the plural form of "child"
$plural = Str::plural('child', 10);
Returns the singular form of "octocat" since count is one
$plural = Str::plural('octocat', 1);
public static quickRandom ( integer $length = 16 ) : string | ||
$length | integer | |
return | string |
Generate a 40 character random alpha-numeric string
echo Str::random(40);
Generate a 16 character random alphabetic string
echo Str::random(16, 'alpha');
Return the "URI" style segments in a given string.
Get the singular form of the given word.
Returns "this-is-my-blog-post"
$slug = Str::slug('This is my blog post!');
Returns "this_is_my_blog_post"
$slug = Str::slug('This is my blog post!', '_');
Convert a string to snake case.
Determine if a string starts with a given needle.
Convert a string to title case
$title = Str::title('taylor otwell');
Convert a multi-byte string to title case
$title = Str::title('νωθρού κυνός');
Convert a string to uppercase
$upper = Str::upper('Taylor Otwell');
Convert a multi-byte string to uppercase
$upper = Str::upper('Τάχιστη');
Convert first letter of each word to uppercase.
public upperWords ( string $string ) : string
$string
string
return
string
Returns "This is a..."
echo Str::words('This is a sentence.', 3);
Limit the number of words and append a custom ending
echo Str::words('This is a sentence.', 3, '---');