lithium\g11n\Multibyte::substr PHP Метод

substr() публичный статический Метод

Multibyte enabled version of substr().
public static substr ( string $string, integer $start, integer $length = null, array $options = [] ) : string
$string string The string to extract the substring from.
$start integer Position of first character in string (offset).
$length integer Maximum numbers of characters to use from string.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
Результат string The substring extracted from given string.
    public static function substr($string, $start, $length = null, array $options = array())
    {
        $defaults = array('name' => 'default');
        $options += $defaults;
        return static::adapter($options['name'])->substr($string, $start, $length);
    }

Usage Example

Пример #1
0
 public function testSubstr()
 {
     Multibyte::substr('abcab', 1);
     $result = $this->adapter->testSubstrArgs;
     $expected = array('abcab', 1, null);
     $this->assertEqual($expected, $result);
     Multibyte::substr('abcab', 1, 2);
     $result = $this->adapter->testSubstrArgs;
     $expected = array('abcab', 1, 2);
     $this->assertEqual($expected, $result);
 }