1. Go to this page and download the library: Download tayron/string-object 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/ */
tayron / string-object example snippets
use Tayron\StringObject;
try{
$pedro = new StringObject('Pedro');
$maria = new StringObject('Pedro');
var_dump($pedro);
var_dump($maria);
var_dump($pedro->isEquals($maria));
var_dump($pedro->length());
$numero = new StringObject('123');
var_dump($numero);
$numero = $numero->parseIntegerObject();
var_dump($numero);
$numero = $numero->parseStringObject();
var_dump($numero);
$numero->replace('3', '999');
var_dump($numero);
$texto = new StringObject('Nome: %s , Idade %d anos');
echo $texto->format(new ArrayObject(array('Pedro', '15'))); // Nome: Pedro, Idade 15 anos
echo $texto->format(new ArrayObject(array('Maria', '32'))); // Nome: Maria, Idade 32 anos
$texto = new StringObject('O rato roeu a roupa do rei de Roma');
echo $texto->wordCount(); // 9
$string = new StringObject();
$string->fillString('748');
$string->fillString('.');
$string->fillString("012.356.356-88", 11, 0, StringObject::LEFT, array('.', '-'));
$string->fillString(' ');
$string->fillString("Maria Betânia da Silva", 15);
$string->fillString("Rua C, número 35", 20);
$string->fillString("Caixa ", 30);
$string->fillString("000");
$string->removeAccentuation();
$string->toUppercase();
$linhaDigitavel1 = $string;
$linhaDigitavel2 = $string;
$linhaDigitavelComplata = $linhaDigitavel1 . PHP_EOL . $linhaDigitavel2;
$arquivo = fopen('teste.txt', 'w');
fwrite($arquivo, $linhaDigitavelComplata);
fclose($arquivo);
Irá criar um arquivo txt com o conteúdo:
748.01235635688 MARIA BETANIA RUA C, NUMERO 35 CAIXA 000
748.01235635688 MARIA BETANIA RUA C, NUMERO 35 CAIXA 000
O que é útil para criar strings com várias informações concatenadas, como por exemplo, criar linha digitável de boleto
}catch(\Exception $e){
echo $e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.