PHP code example of palmtree / string

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

    

palmtree / string example snippets


use function Palmtree\String\s;

$str = s('foo bar baz');

$str->startsWith('foo'); // true
$str->endsWith('baz'); // true
$str->contains('bar'); // true

$str->replace('bar', 'qux'); // 'foo qux baz'

$str->after('bar'); // ' baz'
$str->afterLast('b'); // 'az'
$str->beforeFirst('b'); // 'foo '

$str->kebab(); // 'foo-bar-baz'
$str->camel(); // 'fooBarBaz'
$str->snake(); // 'foo_bar_baz'