PHP code example of dnaber / string-theory

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

    

dnaber / string-theory example snippets



use StringTheory\Type;

$string = new Type\MbString( '苍天有' );

echo $string[ 0 ]; // 苍
echo $string[ 2 ]; // 有 
var_dump( isset( $string[ 3 ] ) ); // false

use StringTheory\Model;

$scanner = new Model\MbScanner( 'abc' );

echo $scanner->current(); // a

$scanner->next();
$scanner->next();
echo $scanner->current(); // c

$scanner->previous();
echo $scanner->current(); // b