1. Go to this page and download the library: Download flextype-components/strings library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flextype-components / strings example snippets
use Flextype\Component\Strings;
$string = Strings::stripSpaces('SG-1 returns from an off-world mission');
$string = Strings::normalizeNewLines('SG-1 returns from an off-world mission');
$string = Strings::normalizeSpaces('SG-1 returns from an off-world mission');
// Get random string with predefined settings
$string = Strings::random();
// Get random string with custom length
$string = Strings::random(10);
// Get random string with custom length and custom keyspace
$string = Strings::random(4, '0123456789');
// Increment string with predefined settings
$string = Strings::increment('page_1');
// Increment string with custom settings
$string = Strings::increment('page-1', 1, '-');
// Returns the number of words found
$result = Strings::wordsCount('SG-1 returns from an off-world mission to P9Y-3C3 with Daniel Jackson');
// Returns an array containing all the words found inside the string
$result = Strings::wordsCount('SG-1 returns from an off-world mission to P9Y-3C3 with Daniel Jackson', 1)
// Returns an associative array, where the key is the numeric position of the word inside the string and the value is the actual word itself
$result = Strings::wordsCount('SG-1 returns from an off-world mission to P9Y-3C3 with Daniel Jackson', 2)
$length = Strings::length('SG-1 returns from an off-world mission to P9Y-3C3');
$string = Strings::lower('SG-1 returns from an off-world mission to P9Y-3C3');
$string = Strings::upper('SG-1 returns from an off-world mission to P9Y-3C3');
// Get string with predefined limit settings
$string = Strings::limit('SG-1 returns from an off-world mission to P9Y-3C3');
// Get string with limit 10
$string = Strings::limit('SG-1 returns from an off-world mission to P9Y-3C3', 10);
// Get string with limit 10 and append 'read more...'
$string = Strings::limit('SG-1 returns from an off-world mission to P9Y-3C3', 10, 'read more...');
$string = Strings::studly('foo_bar');
$string = Strings::snake('fooBar');
$string = Strings::camel('foo_bar');
$string = Strings::kebab('fooBar');
// Get the number of words in a string with predefined limit settings
$string = Strings::words('SG-1 returns from an off-world mission to P9Y-3C3');
// Get the number of words in a string with limit 3
$string = Strings::words('SG-1 returns from an off-world mission to P9Y-3C3', 3);
// Get the number of words in a string with limit 3 and append 'read more...'
$string = Strings::words('SG-1 returns from an off-world mission to P9Y-3C3', 3, 'read more...');
// Determine if a given string contains a given substring.
$result = Strings::contains('SG-1 returns from an off-world mission to P9Y-3C3', 'SG-1');
// Determine if a given string contains a given array of substrings.
$result = Strings::contains('SG-1 returns from an off-world mission to P9Y-3C3', ['SG-1', 'P9Y-3C3']);
$result = Strings::containsAll('SG-1 returns from an off-world mission to P9Y-3C3', ['SG-1', 'P9Y-3C3']);
$result = Strings::containsAny('SG-1 returns from an off-world mission to P9Y-3C3', ['SG-1', 'P9Y-3C3']);
// Returns the portion of string specified by the start 0.
$string = Strings::substr('SG-1 returns from an off-world mission to P9Y-3C3', 0);
// Returns the portion of string specified by the start 0 and length 4.
$string = Strings::substr('SG-1 returns from an off-world mission to P9Y-3C3', 0, 4);
$string = Strings::ucfirst('daniel');
$string = Strings::trim(' daniel ');
$string = Strings::trimRight('daniel ');
$string = Strings::trimLeft(' daniel');
$string = Strings::capitalize('that country was at the same stage of development as the United States in the 1940s');
$string = Strings::reverse('SG-1 returns from an off-world mission');
// Get array of segments from a string based on a predefined delimiter.
$segments = Strings::segments('SG-1 returns from an off-world mission');
// Get array of segments from a string based on a delimiter '-'.
$segments = Strings::segments('SG-1 returns from an off-world mission', '-');
// Get a segment 1 from a string based on a predefined delimiter.
$string = Strings::segment('SG-1 returns from an off-world mission', 1);
// Get a segment 1 from a string based on a delimiter '-'.
$string = Strings::segment('SG-1 returns from an off-world mission', 1, '-');
// Get a segment 1 from a string starting from the last based on a delimiter '-'.
$string = Strings::segment('SG-1 returns from an off-world mission', -1, '-');
// Get a first segment from a string based on a predefined delimiter.
$string = Strings::firstSegment('SG-1 returns from an off-world mission');
// Get a first segment from a string based on a delimiter '-'.
$string = Strings::firstSegment('SG-1 returns from an off-world mission', '-');
// Get a last segment from a string based on a predefined delimiter.
$string = Strings::lastSegment('SG-1 returns from an off-world mission');
// Get a last segment from a string based on a delimiter '-'.
$string = Strings::lastSegment('SG-1 returns from an off-world mission', '-');
$string = Strings::between('SG-1 returns from an off-world mission', 'SG-1', 'from');
$string = Strings::before('SG-1 returns from an off-world mission', 'mission');
$string = Strings::beforeLast('SG-1 returns from an off-world mission', 'mission');
$string = Strings::after('SG-1 returns from an off-world mission', 'SG-1');
$string = Strings::afterLast('SG-1 returns from an off-world mission', 'SG-1');
$string = Strings::padBoth('SG-1 returns from an off-world mission', 50, '-');
$string = Strings::padRight('SG-1 returns from an off-world mission', 50, '-');
$string = Strings::padLeft('SG-1 returns from an off-world mission', 50, '-');
$string = Strings::replaceArray('SG-1 returns from an off-world mission', 'SG-1', ['SG-2']);
$string = Strings::replaceFirst('SG-1 returns from an off-world mission', 'SG-1', 'SG-2');
$string = Strings::replaceLast('SG-1 returns from an off-world mission', 'off-world', 'P9Y-3C3');
// Get string hash with predefined settings
$result = Strings::hash('SG-1 returns from an off-world mission');
// Get string hash with hashed with sha256 algorithm
$result = Strings::hash('SG-1 returns from an off-world mission', 'sha256');
// Get string hash with hashed with sha256 algorithm and with raw output
$result = Strings::hash('SG-1 returns from an off-world mission', 'sha256', true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.