PHP code example of ericmakesstuff / display-name

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

    

ericmakesstuff / display-name example snippets


'EricMakesStuff\DisplayName\DisplayNameServiceProvider',

'DisplayName' => 'EricMakesStuff\DisplayName\Facades\DisplayName',

DisplayName::firstName('John Smith') // John
DisplayName::format('John Smith', 'initials') // JS
 php
$displayName = new EricMakesStuff\DisplayName\DisplayName();
echo $displayName->fullName('John Smith'); // John Smith
echo $displayName->firstName('John Smith'); // John
echo $displayName->firstNameLastInitial('John Smith'); // John S
echo $displayName->firstNameLastInitialWithPeriod('John Smith'); // John S.
echo $displayName->initials('John Smith'); // JS
echo $displayName->initialsWithPeriods('John Smith'); // J.S.
echo $displayName->initialsWithSpaces('John Smith'); // J S
echo $displayName->format('John Smith', 'initials'); // JS