First time you must include src/Str.php in your project for use this helper. Coming soon i will add this project with composer. For Example code you can see in example folder.
Here in list.
- Strip Quotes
- Strip Slashes
- Random String
- Alternator
You can use this helper for string or multiple data with array.
$data = 'Test String "';
Str::strip_quotes($data);
You can use this helper for string or multiple data with array.
$data = 'Test String \' ';
Str::strip_slashes($data);
You can use this helper for random string. Here in list.
- alnum for Alphanumeric
- alpha for Alphabet
- numeric for Numeric
- md5 for MD5
- hex for Hex
- binary for Binary text
Str::random(); // Default is alnum
Str::random(18,'alnum'); //Alnum result
Str::random(18,'alpha'); //Alpha result
Str::random(18,'numeric'); //Numeric result
Str::random(18,'md5'); //MD5 result
Str::random(18,'hex'); //Hex result
Str::random(18,'binary'); //Binary result
You can use this helper for alternating.
for ($i = 0; $i < 10; $i++)
{
echo Str::alternator('one', 'two', 'three', 'four', 'five');
}
You can use this helper to reverse the case of each letter in a string.
$data = 'tESt stRinG';
Str::reverse_case($data);
// Test String
You can use this helper for making a string or array of strings title case.
$data = 'test strinG';
Str::title_case($data);
// Test String
You can use this helper to limit a string or array of strings up to specified length.
$data = 'test string';
Str::limit($data, 4);
// test
You can use this helper to check if specific word or key exists in a string.
$data = 'test string';
Str::contains($data, 'test');
// true