PHP code example of conkal / ztring

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

    

conkal / ztring example snippets


use Conkal\ztring;

use Conkal\ztring;
echo ztring('this is test')->collapseWhitespace()->swapCase(); // THIS IS TEST

$string = \Conkal\ztring::create('test');
foreach ($string as $char) {
    echo $char;
}
// 'test'

$string = \Conkal\ztring::create('test');
count($string);  // 3

$string = \Conkal\ztring::create('test');
echo $string[1];     // 't'

$string = \Conkal\ztring::create('test'); // 'test'

ztring('This is a ')->append('test.'); // This is a test.

ztring('This is a test')->at(0); // 'T'
ztring('This is a test')->at(1); // 'h'
ztring('This is a test')->at(-1); // 't'

ztring('Camel-Case')->camelcase(); // 'camelCase'

ztring('test')->chars(); // ['t','e','s','t']

ztring('This   is a               test')->collapseWhitespace(); // 'This is a test'

ztring('this is a test')->endsWith('test'); // true

ztring('foobar')->ensureLeft('http://'); // 'http://foobar'

ztring('foobar')->ensureRight('.com'); // 'foobar.com'

ztring('test')->firstChar(); // 't'

ztring('test')->first3Chars(); // 'tes'

ztring('test')->lastChar(); // 't'

ztring('test')->last3Chars(); // 'est'

ztring('fòôbàř')->length(); // 6

ztring('Test')->lowerCaseFirst(); // 'test'

ztring('bàř')->prepend('fòô'); // 'fòôbàř'

ztring('This is test.')->replace('This ', 'These '); // 'These is test.'

ztring('fòôbàř')->reverse(); // 'řàbôòf'

\Conkal\ztring::random(); 

ztring('This is a testğüşçö')->slug(); // 'this-is-a-test'

ztring('This is a test')->startsWith('This', false); // true

ztring('This is a test')->substr(0, 4); // 'This'

ztring('Test')->swapCase(); // 'tEST'

ztring('this is a test')->titleCase();
// 'This Is A Test'

  $languageSpecific = [
            'ğ' => 'g',
            'ü' => 'u',
            'ı' => 'i',
            'ş' => 's',
            'ç' => 'c',
            'ö' => 'o',
            'Ğ' => 'G',
            'Ü' => 'U',
            'Ş' => 'S',
            'Ö' => 'O',
            'Ç' => 'C',
            'İ' => 'I',
        ];
ztring('türkçe')->ascii($languageSpecific); // 'turkce'

ztring('OFF')->toBoolean(); // false

ztring('THIS')->lowerCase(); // 'this'

ztring('this is a test')->titleCase(); // 'Fòô Bàř'

ztring('test')->uppercase(); // 'TEST'

ztring('  test  ')->trim(); // 'test'

ztring('this is a test')->upperCaseFirst(); // 'This is a test'

ztring('this is a test')->words(); // ['This', 'is', 'a', 'test']

ztring('this is a test?--*üğişçö')->sanitize(); // 'this is a test'

ztring('This is a test')->acronym(); // 'TIAT'
ztring('This is a test')->acronym('.'); // 'T.I.A.T.'

ztring('1---*?=)(2hjkghkj,iüğ\ş3/*-')->number(); //123