PHP code example of ssolweb / string-morpher
1. Go to this page and download the library: Download ssolweb/string-morpher 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/ */
ssolweb / string-morpher example snippets
use SSolWEB\StringMorpher\StringMorpher as SM;
// you can chain methods
$string = SM::make($string)
->trim()
->replace('fox', 'dog')
->sub(5, 20)
->toLower();
$captalizedAlpha = SM::onlyAlpha($string)
->captalize();
$pascalCase = SM::captalize($string)
->withoutSpaces();
// and use like a string
echo $string;
echo $captalizedAlpha;
$json = json_encode(['data' => $pascalCase]);
// or return string primitive string value
echo $string->getString();