PHP code example of el-gitto-junior / string

1. Go to this page and download the library: Download el-gitto-junior/string 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/ */

    

el-gitto-junior / string example snippets


// returns true
Gears\String\contains('this is a test', 'test');

// returns 'this is a test'
Gears\String\between('<p>this is a test</p>', '<p>', '</p>');

// returns 'cde'
Gears\String\subString('abcdeg', 2, 5);

// Import the functions
use function Gears\String\contains;
use function Gears\String\between;
use function Gears\String\subString;

// returns true
contains('this is a test', 'test');

// returns 'this is a test'
between('<p>this is a test</p>', '<p>', '</p>');

// returns 'cde'
subString('abcdeg', 2, 5);

// Import the string class
use Gears\String as Str;

// returns true
Str::contains('this is a test', 'test');

// returns 'this is a test'
Str::between('<p>this is a test</p>', '<p>', '</p>');

// returns 'cde'
Str::subString('abcdeg', 2, 5);

// using the factory method - returns true
Str::s('This is a test')->contains('test');

// Method chaining is possible - returns 'this is a test'
Str::s('<div><p>this is a test</p></div>')
	->between('<div>', '</div>')
	->between('<p>', '</p>');

foreach (Str::s('I am going to perform a test')->match('/ \w /') as $match)
{
	if ($match->contains('a'))
	{
		echo 'we found the letter a';
	}
}

'Str' => 'Illuminate\Support\Str',

'Str' => 'Gears\String',
/app/config/app.php