PHP code example of danielstjules / sliceable-stringy

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

    

danielstjules / sliceable-stringy example snippets




use SliceableStringy\SliceableStringy as S;

$sliceable = S::create('Fòô Bàř', 'UTF-8');

$sliceable[1];    // 'ò'
$sliceable['-2']; // 'à'

$sliceable[':'];   // 'Fòô Bàř'
$sliceable['4:'];  // 'Bàř'
$sliceable['4:6']; // 'Bà'

$sliceable['-1:'];  // 'ř'
$sliceable[':-1'];  // 'Fòô Bà'
$sliceable['-3:6']; // 'Bà'
$sliceable['2:-6']; // ''

$sliceable['::-1'];   // 'řàB ôòF'
$sliceable['::2'];    // 'FôBř'
$sliceable['-3::-2']; // 'BôF'

$sliceable[20];        // OutOfBoundsException
$sliceable['1:2:3:4']; // InvalidArgumentException, too many slice args
$sliceable['::0'];     // InvalidArgumentException, step cannot equal 0