PHP code example of effectra / to-string

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

    

effectra / to-string example snippets


use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->toUppercase('Hello, World!');
echo $result; // Output: HELLO, WORLD!

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->toLowercase('Hello, World!');
echo $result; // Output: hello, world!

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->strip('<p>Hello, <b>World!</b></p>');
echo $result; // Output: Hello, World!

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$myVariable = 'Hello, World!';
$result = $textToString->nameVar($myVariable);
echo $result; // Output: myVariable

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->textToSlug('Hello, World!');
echo $result; // Output: hello-world

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->slugToText('hello-world');
echo $result; // Output: Hello World

use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->generateRandomText(8);
echo $result; // Output: C4rN1QX7

use Effectra\ToString\ArrayToString;

$result = ArrayToString::array(['apple', 'banana', 'cherry']);
echo $result; // Output: ['apple', 'banana', 'cherry']

use Effectra\ToString\ArrayToString;

$result = ArrayToString::arrayToText(['apple', 'banana', 'cherry']);
echo $result; // Output: apple,banana,cherry

use Effectra\ToString\ArrayToString;

$arrayToString = new ArrayToString();
$result = $arrayToString->arrayToSlug(['apple', 'banana', 'cherry']);
echo $result; // Output: apple-banana-cherry

use Effectra\ToString\ArrayToString;

$arrayToString = new ArrayToString();
$result = $arrayToString->arrayToTextKeyValue(['name' => 'John', 'age' => 25, 'city' => 'New York']);
echo $result;
/*
Output:
name: John,
age: 25,
city: New York,
*/

use Effectra\ToString\DateToString;

$dateToString = new DateToString();
$result = $dateToString->formatTime(3600); // Assuming 3600 seconds is 1 hour
echo $result; // Output: 01:00:00

use Effectra\ToString\DateToString;

$dateToString = new DateToString();
$result = $dateToString->formatDate(time()); // Current timestamp
echo $result; // Output: 2023-05-13