PHP code example of permafrost-dev / laravel-str-extras

1. Go to this page and download the library: Download permafrost-dev/laravel-str-extras 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/ */

    

permafrost-dev / laravel-str-extras example snippets


$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World'
$new = Str::insertAfterMatch('HelloWorld', '/(Hello)/', ' '); // returns 'Hello World'
$new = Str::insertAfter('HelloWorld', 'H', '_'); // returns 'H_elloWorld'

// the identifier in the database is UA-1001, but we want to
// allow the user to provide the identifier without a dash for ease of entry:

$providedIdentifier = 'UA1001';
$actualIdentifier = Str::insertAfter($providedIdentifier, 'UA', '-'); 
$userExists = User::where('identifier', $actualIdentifier)->exists();

$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World'