1. Go to this page and download the library: Download torugo/tstring 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/ */
torugo / tstring example snippets
use Torugo\TString\Traits\Validators\TStringContains;
class MyClass()
{
use TStringContains;
public function myValidation() {
// ...
if (self::contains($haystack, $needle, false)) {
// Do something...
}
// ...
}
}
use Torugo\TString\TString;
if (TString::contains($haystack, $needle, false)) {
// Do something
}
new UrlOptions(
: false, // expects the protocol to be present in the url
rue,
alse,
allowFragments: true,
allowQueryComponents: true,
allowAuth: true,
allowNumericTld: false,
allowWildcard: false,
validateLength: true,
);
maxLength(string $str, int $max): bool
use Torugo\TString\Traits\Validators\TStringMaxLength;
maxLength('pSqKDfErCG5zTkmh', 18); // returns true
maxLength('cETíÁ4ÃR9k=Hj7óGÜt@8', 20); // returns true
maxLength('DXaEbx', 5); // returns false
maxLength('X', 0); // sets max parameter to 1 and returns true
maxLength('Y', -1); // sets max parameter to 1 and returns true
minLength(string $str, int $min): bool
use Torugo\TString\Traits\Validators\TStringMinLength;
minLength('kfRb7qhmdWear4X9', 15); // returns true
minLength('jCa3xMe9GZ82pmKu', 16); // returns true
minLength('afdvkxzeg9AwrB8D57XE3pj', 24); // returns false
minLength('Y', -1); // sets min parameter to 0 and returns true
use Torugo\TString\Traits\Handlers\TStringToLowerCase;
toLowerCase('LUKE I AM YOUR FATHER'); // returns 'luke i am your father'
toLowerCase('R2D2'); // returns 'r2d2'
toLowerCase('JOSÉ DE ALENCAR'); // returns 'josé de alencar'
use Torugo\TString\Traits\Handlers\TStringToTitleCase;
// WITH DEFAULT OPTIONS
toTitleCase('LUKE SKYWALKER'); // returns 'Luke Skywalker'
toTitleCase('carlos drummond de andrade'); // returns 'Carlos Drummond De Andrade'
toTitleCase('Pope Gregory XIII'); // returns 'Pope Gregory Xiii'
// FIXING ROMAN NUMERALS
toTitleCase('pope gregory xiii', true, false); // returns 'Pope Gregory XIII'
toTitleCase('DALAI LAMA XIV', true, false); // returns 'Dalai Lama XIV'
// FIXING PORTUGUESE PREPOSITIONS
toTitleCase('NISE DA SILVEIRA', false, true); // returns 'Nise da Silveira'
toTitleCase('Tarsila Do Amaral', false, true); // returns 'Tarsila do Amaral'
// BOTH OPTIONS ENABLED
toTitleCase('xv de piracicaba', true, true); // returns 'XV de Piracicaba'
toTitleCase('JOSÉ BONIFÁCIO DE ANDRADA E SILVA II', true, true); // returns 'José Bonifácio de Andrada e Silva II'
toUpperCase(string $str): string
use Torugo\TString\Traits\Handlers\TStringToUpperCase;
toUpperCase('may the force be with you'); // returns 'MAY THE FORCE BE WITH YOU'
toUpperCase('c3po'); // returns 'C3PO'
toUpperCase('Cecília Meireles'); // returns 'CECÍLIA MEIRELES'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.