PHP code example of basteyy / php-stringer

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

    

basteyy / php-stringer example snippets


echo basteyy\Stringer\escapeString('<script>alert("hello")</script>');
// Output: &lt;script&gt;alert(&quot;hello&quot;)&lt;/script&gt;

echo basteyy\Stringer\getStringHashSum('yourStringHere');
// Output: [sha256 hash of 'yourStringHere']

echo basteyy\Stringer\remove_double_slashes('https://example.com//path//');
// Output: https://example.com/path/

echo basteyy\Stringer\getSlugifiedText('Hello World! How are you?');
// Output: hello-world-how-are-you

echo basteyy\Stringer\slugify('This is a Test String!');
// Output: this-is-a-test-string

echo basteyy\Stringer\getRandomAlphaNumericString(10);
// Output example: "1a2b3c4d5e"

echo basteyy\Stringer\getRandomNumericString(10);
// Output example: "1234567890"

echo basteyy\Stringer\getRandomAlphaString(10);
// Output example: "aBcDeFgHiJ"

echo basteyy\Stringer\getRandomString(10, '!@#$%^&*()');
// Output example: "%$@!^&*!@"

$password = basteyy\Stringer\createMemorablePassword(2, 2, 2, true);
echo $password;

// Standard usage with default unit names
echo basteyy\Stringer\Times\getNiceTimeAgo('2023-01-01 00:00:00');
// Output example: "2 months ago"

// Exact output
echo basteyy\Stringer\Times\getNiceTimeAgo('2023-01-01 00:00:00', true);
// Output example: "2 months, 3 days, 4 hours, 5 minutes, 6 seconds ago"

// Custom unit names
$customUnitMap = [
    'second' => ['Sekunde', 'Sekunden'],
    'minute' => ['Minute', 'Minuten'],
    // ... other units
];
echo basteyy\Stringer\Times\getNiceTimeAgo('2023-01-01 00:00:00', false, $customUnitMap);
// Output example: "2 Monate ago"
bash
composer