PHP code example of pixel418 / ubiq

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

    

pixel418 / ubiq example snippets


$string = 'example.com/my/path';
\UString::substrBefore( $string, '/' );
// Returns 'example.com'
// Instead of usual implementation: substr( $string, 0, strpos( $string, '/' ) );

$string = 'example.com/my/path';
\UString::substrBefore( $string, '/' );
// Returns 'example.com'

\UString::substrBefore( $string, [ '/', '.' ] );
// Returns 'example'

\UString::substrBeforeLast( $string, [ '/', '.' ] );
// Returns 'example.com/my'

$string = 'my/path';
// Without prefix, the method return the result of the treatment
\UString::startWith( $string, '/' );
// Returns '/my/path'

$string = 'my/path';
// With 'is' prefix, the method return the result of the test
\UString::isStartWith( $string, '/' );
// Returns FALSE

$string = 'my/path';
// With 'do' prefix, the method treat by reference
\UString::doStartWith( $string, '/' );
// $string value is now '/my/path'