PHP code example of dakujem / shorts

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

    

dakujem / shorts example snippets


Shorts::cap('Pablo Escobar', 10); // "P. Escobar"
Shorts::cap('Pablo Escobar', 2); // "PE"

Shorts::cap('John Ronald Reuel Tolkien', 20); // "John R. R. Tolkien"
Shorts::cap('John Ronald Reuel Tolkien', 16); // "J. R. R. Tolkien"
Shorts::cap('John Ronald Reuel Tolkien', 15); // "J.R.R. Tolkien"
Shorts::cap('John Ronald Reuel Tolkien', 8);  // "J.R.R.T."
Shorts::cap('John Ronald Reuel Tolkien', 4);  // "JRRT"

Shorts::cap('Pablo Escobar', 10, Shorts::FIRST_NAME); // "Pablo E."

Shorts::shrink('John Ronald Reuel Tolkien'); // "J. R. R. Tolkien"
Shorts::shrink('Hugo Ventil');               // "H. Ventil"

Shorts::shrink('John Ronald Reuel Tolkien', Shorts::FIRST_NAME); // "John R. R. T."
Shorts::shrink('Hugo Ventil', Shorts::FIRST_NAME);               // "Hugo V."

Shorts::initials('John Ronald Reuel Tolkien'); // "JRRT"
Shorts::initials('Hugo Ventil');               // "HV"

Shorts::initials('John Ronald Reuel Tolkien', '.', ' '); // "J. R. R. T."
Shorts::initials('Hugo Ventil', '.', ' ');               // "H. V."

Shorts::i()->limit( ... );      // Shorts::cap( ... )
Shorts::i()->reduce( ... );     // Shorts::shrink( ... )
Shorts::i()->toInitials( ... ); // Shorts::initials( ... )

Shorts::i()->limiter( ... )
Shorts::i()->reducer( ... )
Shorts::i()->initialsFormatter( ... )

$fmt = Shorts::i()->limiter(20); // will limit any input to 20 chars
$fmt('Foo Bar'); // this is equivalent to  Shorts::cap('Foo Bar', 20)