PHP code example of kzykhys / text

1. Go to this page and download the library: Download kzykhys/text 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/ */

    

kzykhys / text example snippets




use KzykHys\Text\Text;

$text = new Text('Lorem Ipsum');
echo $text;

// Lorem Ipsum



use KzykHys\Text\Text;

$text = Text::create('Lorem Ipsum');
echo $text;

// Lorem Ipsum
 php
$text = new Text('foo');
$text
    ->append('bar')     // foobar
    ->prepend('baz')    // bazfoobar
    ->wrap('-')         // -bazfoobar-
    ->upper()           // -BAZFOOBAR-
    ->lower()           // -bazfoobar-
    ->trim('-')         // bazfoobar
    ->rtrim('r')        // bazfooba
    ->ltrim('b')        // azfooba
;
 php
$text = new Text('FooBarBaz');
$text->replace('/Foo(Bar)(Baz)/', function (Text $whole, Text $bar, Text $baz) {
    return $bar->upper()->append($baz->lower());
});
echo $text;

// BARbaz