PHP code example of bayfrontmedia / php-string-helpers

1. Go to this page and download the library: Download bayfrontmedia/php-string-helpers 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/ */

    

bayfrontmedia / php-string-helpers example snippets


use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::startWith($string, 'Hello! ');

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::endWith($string, ' Goodbye!');

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::lowercase($string);

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::uppercase($string);

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::titleCase($string);

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::camelCase($string);

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::kebabCase($string);

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

echo Str::snakeCase($string);

use Bayfront\StringHelpers\Str;

echo Str::random(16, Str::RANDOM_TYPE_ALPHANUMERIC);

use Bayfront\StringHelpers\Str;

echo Str::uid(16);

use Bayfront\StringHelpers\Str;

echo Str::uuid4();

use Bayfront\StringHelpers\Str;

echo Str::uuid7();

use Bayfront\StringHelpers\Str;

if (!Str::hasComplexity('abc123', 8, 32, 1, 1, 1, 1)) {
    // Do something
}

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

if (Str::has($string, 'this')) {

    // Do something

}

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

if (Str::hasSpace($string)) {

    // Do something

}

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

if (Str::startsWith($string, 'this')) {

    // Do something

}

use Bayfront\StringHelpers\Str;

$string = 'This is a string.';

if (Str::endsWith($string, 'string.')) {

    // Do something

}

use Bayfront\StringHelpers\Str;

echo Str::uuid();