1. Go to this page and download the library: Download omar-haris/card-name-fit 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/ */
omar-haris / card-name-fit example snippets
use CardNameFit\NameFormatter;
// Create a formatter with 20-character limit
$formatter = new NameFormatter(20);
// Format some names
echo $formatter->format('John William Smith'); // "John William Smith"
echo $formatter->format('John William Alexander Smith'); // "John William Smith"
// Works with Arabic names too
echo $formatter->format('محمد عبد الرحمن العبد الله'); // "محمد عبد الرحمن"
// With 20 character limit
$formatter = new NameFormatter(20, NameFormatter::ENGLISH_GREEDY);
echo $formatter->format('John Smith'); // "John Smith"
echo $formatter->format('John William Smith'); // "John William Smith"
echo $formatter->format('John William Alexander Smith'); // "John William Smith"
// (drops "Alexander")
// With 20 character limit
$formatter = new NameFormatter(20, NameFormatter::ENGLISH_DENSE);
echo $formatter->format('John William Alexander Smith'); // "John W. A. Smith"
// (
$formatter = new NameFormatter(25);
echo $formatter->format('محمد عبد الرحمن العبد الله'); // "محمد عبد الرحمن"
$formatter = new NameFormatter(20);
// Long last name
echo $formatter->format('John Wolfeschlegelsteinhausenbergerdorff');
// "John Wolfeschlegelst"
$formatter = new NameFormatter(20);
echo $formatter->format(' John William Smith '); // "John William Smith"
/**
* @param int $maxLength Maximum allowed characters (≥ 1)
* @param string $englishMode Strategy: ENGLISH_GREEDY or ENGLISH_DENSE
* @param string $encoding Character encoding (default: UTF-8)
*/
public function __construct(
int $maxLength = 35,
string $englishMode = self::ENGLISH_GREEDY,
string $encoding = 'UTF-8'
)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.